Code for sorting loads.