sort the ordering out