static void Main(string[] args) { int inputAmount = 3; int splitAmount = 50; string splitSymbol = "="; TwoWayLinkedList <string> linkedList = new TwoWayLinkedList <string> { "1", "0", "BNTU", "Videos", "Math", "C# better than Java", "python not so good", "hello world!", "How do you do", "London is the capital of GB" }; for (int i = 0; i < inputAmount; i++) { Console.WriteLine("Введите данные: "); linkedList.Add(Console.ReadLine()); } Center(splitAmount, "Unsorted list:", splitSymbol); linkedList.Print(); SortLinkedList.Sort(linkedList); Center(splitAmount, "Sorted list:", splitSymbol); linkedList.Print(); }
public static void Sort <T>(TwoWayLinkedList <T> linkedList) where T : IComparable { for (int i = 0; i < linkedList.Length; i++) { for (int j = i + 1; j < linkedList.Length; j++) { if (linkedList[i].CompareTo(linkedList[j]) > 0) { linkedList.SwapValue(linkedList.GetNodeByIndex(i), linkedList.GetNodeByIndex(j)); } } } }
public LinkedListEnumerator(TwoWayLinkedList <T> linkedList) { list = linkedList; }