Improve location sorting

Adds optimisation to location minimum calculation and stores
location minimum information into CDS object.