Fix errors in perf_sort_by_key