Sort a linked list in O(nlgn) time