asort( ) function sorts array by its values while preserving the keys
//bool arsort ( array &arr [, int options] )
<?
$capitalcities['England'] = 'London';
$capitalcities['Wales'] = 'Cardiff';
$capitalcities['Scotland'] = 'Edinburgh';
asort($capitalcities);
// sorted by value, so Cardiff, Edinburgh, London
?>
Related examples in the same category