The first thing you need to do is read the sorting algorithms and decide which one you are going to use. Once you do this, you can worry about comparing your common values.
If you want to follow a framework approach, don't require your T to implement IComparable<T>. Use Comparer<T>.Default . This approach allows you to write your own class to support custom comparisons:
public class LinkedList<T> { public void Sort() { this.Sort(Comparer<T>.Default); } public void Sort(IComparer<T> comparer) {
In my original version of this answer, there was a resolver as a class property, but this is really wrong because the linked list is not sorted by default. You can sort the list once once, and then after 2 seconds, sort it differently. Therefore, the comparator must be a parameter of the sorting method.
phoog source share