This is my array:
$arr = array(-3, -4, 1, -1, 2, 4, -2, 3);
I want to sort it like this:
1
2
3
4
-1
-2
-3
-4
So first there would be values greated than zero sorted from the lowest value to the highest value, then there would be negative values sorted from the highest value to the lowest value.
Is there some elegant way to do this?
Here’s a non-
usort()method, assuming zero is irrelevant…EDIT: no PHP 5.3? Use
create_function()as you say: