I have an array as follows:
Array(
[27] => \'Sarah Green\',
[29] => \'Adam Brown\',
[68] => \'Fred Able\'
);
I\'d like
I don't think you could directly do this with PHP's built-in array sorting - although I would be interested if someone corrected me on this.
The easiest way would be to reverse the names so that it becomes Green, Sarah because then you could use PHPs own sorting functions e.g. using asort() (which maintains the key association).
If that isn't feasible you will probably need to implement your own custom sorting function. The easiest way of doing that, is to use usort() which allows you to define a custom comparator function. So for example:
usort($arr, "sortByLastName");
function sortByLastName($a, $b) {
//DO YOUR COMPARISON IN HERE
}