AC version. Quick sort for linked-list