Sorting on x,y,z before printing