Finish log_sort() and its test.