static void InsertionSort() { var unsortedList = new SortingList(10); var sortedList = new SortingList(unsortedList.Length); /* Let's fill the unsorted list with all sorts of junk */ unsortedList.randimise(10); unsortedList.Print(); /* This is where we do the insertion sort-- doesn't * object oriented make this look easy? */ for (int i = 0; i < unsortedList.i; i++) { sortedList.Insert(unsortedList.Pop()); } sortedList.print(); }
static void Main(string[] args) { var unsortedList = new SortingList(10); var sortedList = new SortingList(unsortedList.Length); var Bubblelist = new SortingList2(10); /* Let's fill the unsorted list with all sorts of junk */ unsortedList.Randomise(); unsortedList.Print(); Bubblelist.Print(); Bubblelist.Sort(); /* This is where we do the insertion sort-- doesn't * object oriented make this look easy? */ for (int i = 0; i < unsortedList.Length; i++) { sortedList.Insert(unsortedList.Pop()); } sortedList.Print(); }