Sorting a multiarray
Posted: Fri Aug 22, 2008 10:39 pm
This is supposed to be a simple thing turned complicated. I got a multi array:
$members_list[key, array]
ie:
$members_list[0, ['a' => 1; 'b' => 'name']]
$members_list[88, ['a' => 1; 'b' => 'name']]
$members_list[25, ['a' => 1; 'b' => 'name']]
$members_list[0, ['a' => 1; 'b' => 'name']]
All i'm trying to do it organize the $members_list by the key using ksort.
ksort($members_list);
But it doesn't. for some reason it just doesn't sort anything at all. The data is pulled from a mysql db, and put into the array which is $members_list's value.
IF is key($members_list) it ill turn up to be the 0,88,25,0,... so why isn't it sorting.
I first thought it to be a string so i intval() to make sure. Then i even tried adding that key to the ['sort' => 0, 'a' => 1, 'b' => 'name'] but the result is the same: nothing.
I'm using each members calculated % so i have mixed numbers. Just wondering what was your thoughts on this. I'm sure i'm doing something wrong just can't figure it out.
Thanks for your help.
$members_list[key, array]
ie:
$members_list[0, ['a' => 1; 'b' => 'name']]
$members_list[88, ['a' => 1; 'b' => 'name']]
$members_list[25, ['a' => 1; 'b' => 'name']]
$members_list[0, ['a' => 1; 'b' => 'name']]
All i'm trying to do it organize the $members_list by the key using ksort.
ksort($members_list);
But it doesn't. for some reason it just doesn't sort anything at all. The data is pulled from a mysql db, and put into the array which is $members_list's value.
IF is key($members_list) it ill turn up to be the 0,88,25,0,... so why isn't it sorting.
I first thought it to be a string so i intval() to make sure. Then i even tried adding that key to the ['sort' => 0, 'a' => 1, 'b' => 'name'] but the result is the same: nothing.
I'm using each members calculated % so i have mixed numbers. Just wondering what was your thoughts on this. I'm sure i'm doing something wrong just can't figure it out.
Thanks for your help.