Using PHP 5.x.
I would like to sort a set of values first numerically, then alphabetically. For example, here's my code so far:
Code:
<?php
print "<p style=\"font-family:verdana;font-size:10pt\">\n";
$myArray = array("1223:starfruit", "34112:oranges", "1223:zucchini", "321:apples", "34112:pears", "1223:tomatoes");
rsort($myArray, SORT_NUMERIC);
for($i = 0; $i <= count($myArray); $i++) {
print "$myArray[$i]<br />\n";
}
print "</p>\n";
?>
The output is this:
Code:
34112:pears
34112:oranges
1223:tomatoes
1223:zucchini
1223:starfruit
321:apples
I would like the output to be this instead:
Code:
34112:oranges
34112:pears
1223:starfruit
1223:tomatoes
1223:zucchini
321:apples
I have fiddled with array_multisort but I can't seem to get my head around it or the many sort routines in PHP. Help would be appreciated.