Sorting an array with uksort()

gonetohel

New Member
I have an array like this one:\[code\]$a = array("MA1" => 0, "MA10" => 1, "MA20" => 2, "MA5" => 3, "SM10" => 4, "SM8" => 5, "SM20" => 6, "SN33" => 7);\[/code\]I want to sort it, that I will have the following order:\[code\]$a = array("MA1" => 0, "MA5" => 3, "MA10" => 1, "MA20" => 2, "SM8" => 5, "SM10" => 4, "SM20" => 6, "SN33" => 7);\[/code\]So I need a order which is alphabetical within the first two chars and numeric of the rest. So I think I have to do this with\[code\]uksort($a, "cmp");\[/code\]So I need a function like this:\[code\]function cmp($a, $b) { // ??? return strcasecmp($a, $b);}\[/code\]How do I need to write the function so that the order will be right?Thank you in advance & Best Regards.
 
Back
Top