Samuel said:
Isn't sorting basically looping and then swapping individual elements,
not really arbitrary access to somewhere in the list? A double-linked
list is just fine for sorting 'cause it's easy enough to change the
references in the nodes and swap items. Not as easy as swapping items
in an array, but not a huge problem either.
Well, consider quick sort - it starts off each iteration by picking a
pivot, often by taking the half-way point within the list/sublist. That
requires an O(n) operation in a linked list. I haven't examined the
other types of sort in detail, but I suspect they would have similar
problems.
Something like a bubble sort is very easy to achieve in a linked list,
but I suspect that most of the other sorts are at least tricky to
achieve efficiently. Put it this way, you certainly wouldn't want to
use the same code to sort both types of list, even if they used the
same algorithm.
Having said all this, I did a quick search for sorting linked lists,
and a very reliable source (a friend from university

has written up
applying mergesort to linked lists - apparently it works well:
http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
Interestingly, wikipedia has this to say (in its Mergesort page):
<quote>
Merge sort is often the best choice for sorting a linked list: in this
situation it is relatively easy to implement a merge sort in such a way
that it requires only T(1) extra space, and the slow random-access
performance of a linked list makes some other algorithms (such as
quicksort) perform poorly, and others (such as heapsort) completely
impossible.
</quote>
So it looks like my original assessment was half-right: you basically
need to treat sorting linked lists differently, and shouldn't expect
the "normal" algorithms to do well, but it's doable. It's worth noting
that the Java "I sort any list" method
java.util.Collections.sort(List<T>) achieves n log(n) performance by
dumping the list into an array, performing a merge sort on it, then
resetting the contents of the original list.
Jon