Fix errors in perf_sort_by_key

Fixes #84.