more elegant rounded-group-by-sort-etc., via Jacqui