Fixed sorting of top level boundaries