Sorting before printing