public static LinkedList <WordBox> sortWordsByAlphabet(LinkedList <WordBox> words) { for (LinkedListNode <WordBox> firstIter = words.First; firstIter.Next != null; firstIter = firstIter.Next) { for (LinkedListNode <WordBox> secondIter = firstIter; secondIter.Next != null; secondIter = secondIter.Next) { if (String.Compare(firstIter.Value.Word.Value, secondIter.Value.Word.Value) > 0) { WordBox buf = firstIter.Value; firstIter.Value = secondIter.Value; secondIter.Value = buf; } } } return(words); }
public static LinkedList <WordBox> SortWords(LinkedList <WordBox> words, ComparatorForBox compare) { for (LinkedListNode <WordBox> firstIter = words.First; firstIter != null; firstIter = firstIter.Next) { for (LinkedListNode <WordBox> secondIter = firstIter; secondIter != null; secondIter = secondIter.Next) { if (compare(firstIter.Value, secondIter.Value)) { WordBox buf = firstIter.Value; firstIter.Value = secondIter.Value; secondIter.Value = buf; } } } return(words); }