You need to sort multiple times. On the first time, sort on the
least significant columns (typically the right-most columns), and
then sort on the more significant columns (typically the
left-most columns). Work your way from least to most
significant.