public Compare ( object x, object y ) : int | ||
x | object | First object to be compared |
y | object | Second object to be compared |
리턴 | int |
public List <ListViewItem> GetItemGroupSorted(EDeviceState state) { ListViewGroup activeGroup = GetItemGroup(EDeviceState.Active); List <ListViewItem> list = activeGroup.Items.OfType <ListViewItem>().Select(i => i).ToList(); ListViewColumnSorter sorter = m_listDevices.ListViewItemSorter as ListViewColumnSorter; list.Sort((i1, i2) => ListViewColumnSorter.Compare(i1, i2, sorter.SortColumn, sorter.SortOrder)); return(list); }
public static void Sort(ArrayList array, ListViewColumnSorter compare) { //quick sort - unstable //array.Sort(compare); //insertion sort - stable int i; int j; object index; for (i = 1; i < array.Count; i++) { index = array[i]; j = i; while ((j > 0) && (compare.Compare(array[j - 1], index) > 0)) { array[j] = array[j - 1]; j = j - 1; } array[j] = index; } //old bubble sort - stable /*bool change = false; * * for (int i = 0; i < array.Count; i++) * { * for (int j = 0; j < array.Count - i - 1; j++) * { * if (compare.Compare(array[j], array[j + 1]) > 0) * { * array.Reverse(j, 2); * change = true; * } * } * * if (!change) * { * //no changes...fully sorted * return; * } * }*/ }
public static void Sort(ArrayList array, ListViewColumnSorter compare) { //quick sort - unstable //array.Sort(compare); //insertion sort - stable int i; int j; object index; for (i = 1; i < array.Count; i++) { index = array[i]; j = i; while ((j > 0) && (compare.Compare(array[j - 1], index) > 0)) { array[j] = array[j - 1]; j = j - 1; } array[j] = index; } //old bubble sort - stable /*bool change = false; for (int i = 0; i < array.Count; i++) { for (int j = 0; j < array.Count - i - 1; j++) { if (compare.Compare(array[j], array[j + 1]) > 0) { array.Reverse(j, 2); change = true; } } if (!change) { //no changes...fully sorted return; } }*/ }