mergegroups: add sort