There’s a few questions discussing Merge sorting a LinkedList, but how can I do it with the C# LinkedList?
Since the LinkedListNode Next and Previous properties are read-only most of the in-place algorithms I’ve come across are not possible.
I’ve resorted to removing all the nodes, sorting them with a .OrderBy(node => node.Value) and then re-inserting them into the Linked list, but it’s fairly crude.
You can re-order nodes by calling
Remove, thenAddAfter.