Apply vtjnash suggestion to avoid copy on sort.