/// <summary> /// Sorts an attributes collection alphabeticlly. /// Uses bubble sort. /// </summary> /// <param name="a_toSort">The attribute collection to sort.</param> public static void SortAttributes(XmlAttributeCollection a_toSort) { if (a_toSort == null) { return; } bool l_change = true; while (l_change) { l_change = false; for (int i=1; i<a_toSort.Count; i++) { if (String.Compare(a_toSort[i].Name, a_toSort[i-1].Name, true) < 0) { //Replace a_toSort.InsertBefore(a_toSort[i], a_toSort[i-1]); l_change = true; } } } }
/// ----------------------------------------------------------- /// <summary> /// Sorts an attributes collection alphabetically. /// It uses the bubble sort algorithm. /// </summary> /// <param name="attribCol">The attribute collection to be sorted.</param> /// ----------------------------------------------------------- public static void SortAttributes(XmlAttributeCollection attribCol) { if (attribCol == null) return; bool hasChanged = true; while (hasChanged) { hasChanged = false; for (int i = 1; i < attribCol.Count; i++) { if (String.Compare(attribCol[i].Name, attribCol[i - 1].Name, true) < 0) { //Replace attribCol.InsertBefore(attribCol[i], attribCol[i - 1]); hasChanged = true; } } } }