Added implementation for list_sort.