/* * Name: Sort * Purpose: Uses bubble sort to sort an array from lowest to highest or vice versa depending on the BubbleSortOptions. * Parameters: ulong list * Returns: ulong list */ public static List <ulong> Sort(List <ulong> numbers, BubbleSortOptions options) { if (options == BubbleSortOptions.LowToHigh) { return(Sort(numbers)); } else { List <ulong> sortedNumbers = numbers; for (int i = 0; i < sortedNumbers.Count; i++) { for (int i2 = 0; i2 < sortedNumbers.Count; i2++) { if (sortedNumbers[i] > sortedNumbers[i2]) { ulong temp = sortedNumbers[i2]; sortedNumbers[i2] = sortedNumbers[i]; sortedNumbers[i] = temp; } } } return(sortedNumbers); } }
/* * Name: Sort * Purpose: Uses bubble sort to sort an array from lowest to highest or vice versa depending on the BubbleSortOptions. * Parameters: ulong array * Returns: ulong array */ public static ulong[] Sort(ulong[] numbers, BubbleSortOptions options) { if (options == BubbleSortOptions.LowToHigh) { return(Sort(numbers)); } else { ulong[] sortedNumbers = numbers; for (uint i = 0; i < sortedNumbers.Length; i++) { for (uint i2 = 0; i2 < sortedNumbers.Length; i2++) { if (sortedNumbers[i] > sortedNumbers[i2]) { ulong temp = sortedNumbers[i2]; sortedNumbers[i2] = sortedNumbers[i]; sortedNumbers[i] = temp; } } } return(sortedNumbers); } }