I have written a basic linked list class in C#. It has a Node object, which (obviously) represents every node in the list.
The code does not use IEnumerable, however
The simplest option is probably to extract the data, sort it in a mechanism that already supports sorting (arrays, List
or IEnumerable
via LINQ), and re-build the linked list with the sorted data.
If you want to write your own sort algorithm, then you may find Comparer
useful (assuming you are using generics). This should allow you to compare any items that are IComparable
or IComparable
.
As an aside - note that .NET already includes LinkedList
etc; if this is just for learning etc, then fine ;-p