Fix multiple sort criteria

With larger datasets (not browser vs node), sorting by multiple criteria was incorrect. Now, instead of sorting the array multiple times, multiple criteria are considered in a single pass.

I've added a test that used a sufficient amount of data to consistently fail under the old sort routine.