Improve grouping sort allocation