Fixed sort when grouping