Sort pairs of blocks to achieve optimal thread processing