An easy way to tackle this is to restructure your array and use asort
$enterprises = array();
//Ex.: Array ( [0] => Array ( [A0A0A0] => 0 ) [1] => Array ( [A0A1A0] => 22.794344863539 )
for ($i=0; $i < count($cpEnterprise) ; $i++) {
$enterprises[$cpEnterprise[$i]] = distance($actualCpLat, $actualCpLong, $businessLat[$i], $businessLong[$i], 'k');
}
asort($enterprises);