I have an array that has a layout:
$array[0][0] = "Something";
$array[0][1] = 20;
$array[1][0] = "Something else";
$array[1][1] = 50;
Is there an existing funtion to sort descending by the numeric value?
Sorting an array by a keys value in the array
Moderator: General Moderators
-
impulse()
- Forum Regular
- Posts: 748
- Joined: Wed Aug 09, 2006 8:36 am
- Location: Staffordshire, UK
- Contact:
No problem:
I'd want key 1 of the array to be top of the list because 50 is the higher value and array key 0 to be bottom of the list because it's the lower number. I'll add some more values so it's more understandable.
Before sort:
After sort:
If there are still problems understanding then let me know.
I'd want key 1 of the array to be top of the list because 50 is the higher value and array key 0 to be bottom of the list because it's the lower number. I'll add some more values so it's more understandable.
Before sort:
Code: Select all
$array[0][0] = "Something";
$array[0][1] = 20;
$array[1][0] = "Something else";
$array[1][1] = 50;
$array[2][0] = "Something else again";
$array[2][1] = 13;
$array[3][0] = "Last time";
$array[3][1] = 400;Code: Select all
$array[3][0] = "Last time";
$array[3][1] = 400;
$array[1][0] = "Something else";
$array[1][1] = 50;
$array[0][0] = "Something";
$array[0][1] = 20;
$array[2][0] = "Something else again";
$array[2][1] = 13;