partial_sort_copy and tests