static void Main() { DrugList drugs = new DrugList("RXQT1402.txt"); drugs.SelectSort(); foreach (Drug d in drugs.ToArray()) { Console.WriteLine(d); } }
// Sort this list by insertion sorts public void InsertSort() { //this method places the Drug object in a new Node of the linked list //just before the first element greater than the new element under //the comparison method. DrugList sortedList = new DrugList(); Drug tmp = RemoveFirst(); while (tmp != null) { sortedList.InsertInOrder(tmp); tmp = RemoveFirst(); } head = sortedList.head; tail = sortedList.tail; count = sortedList.count; }
// Methods which sort the list: // Sort this list by selection sort. public void SelectSort() { //this methods keeps on calling the removemin method //it always places the new min in the beginning of the list //in order to have a sorted list DrugList sortedList = new DrugList(); Drug tmp = RemoveMin(); while (tmp != null) { Console.WriteLine(count); sortedList.Append(tmp); tmp = RemoveMin(); } head = sortedList.head; tail = sortedList.tail; count = sortedList.count; }