merging in the sort functionality from the sandbox