Slightly refactored final sorter to make more similar to first-level sorters. This is in preparation for #15.