private static int Split(ISimpleList <int> list, int start, int end) { var pivot = list[end]; var wall = start; for (int i = start; i < end; i++) { if (list[i] > pivot) { continue; } list.Swap(wall, i); wall++; } list.Swap(wall, end); return(wall); }
public static void BubbleSort(this ISimpleList <int> list) { for (int i = list.Count; i > 1; i--) { for (int j = 1; j < i; j++) { if (list[j - 1] > list[j]) { list.Swap(j - 1, j); } } } }
public static void SelectSort(this ISimpleList <int> list) { for (int i = 0; i < list.Count - 1; i++) { var minIndex = i; for (int j = i + 1; j < list.Count; j++) { if (list[minIndex] > list[j]) { minIndex = j; } } list.Swap(minIndex, i); } }