fixed sorting for reports with grouping