BVS-711: Fix sorting to correctly process the order of 'external' and 'any'