tuple sorter for multi-groupbys