I am looking for the cleanest ways to sort array alphabetically and by strlen in PHP. The cleanest way i came up with to sort by strlen is this:
array_multisort(array_map('strlen', $array), $array);
How would i extend this to sort alphabetically by values as the primary sorting?
This is an example array:
array('name'=>'Firstname','name2'=>'Lastname1','name3'=>'Lastname2')
The order after the sort function is not important, what is important is that it always returns the same order when sorted, regardless the same length of some values. The array keys are not needed after sort.