Fixed sort-related bugs, and made sure that index-related sorting uses the same memory/compression options that general sorting does