Reputation:
I would like to sort an array like:
$k = array (
"2135p" => "toto",
"2137l" => "tosdgsto",
"2135p^2211i" => "sdf",
"2135p^2211i^2224o" => "sdf",
"2137l^2365c" => "sdff"
);
with this order -> "2137l", "2137l^2365c", "2135p", "2135p^2211i", "2135p^2211i^2224o"
krsort doesn't do it
It's for displaying inset comments ids
thanks
Upvotes: 0
Views: 317
Reputation: 71414
You will likely need to implement your own uksort()
implementation to get what you need.
Upvotes: 1
Reputation: 26773
Pass krsort()
the SORT_NUMERIC
flag and it should work.
Alternately use the uksort()
function: https://www.php.net/manual/en/function.uksort.php and define your own comparator.
Upvotes: 0