Hi everyone...!
I need some help figuring out this Usort thing...
I have a multidimensional array like this...
$output[$i][0]='ID'
$output[$i][1]='First'
$output[$i][2]='Last'
$output[$i][3]='Age'
When I display it in a table I get this...
1 Joe Blow 25
2 Jane Doe 5
3 Jimmy Chu 23
4 Paul Pile 30
I want it to be like this...
4 Paul Pile 30
1 Joe Blow 25
3 Jimmy Chu 23
2 Jane Doe 5
After the array is loaded I am sorting it using the following code...
// Function for sorting the new array...
function cmp ($a,$b)
{
// the [3] is the column I am sorting by
$cmp = strcmp($a[3],$b[3]);
return $cmp ? $cmp : -1;
}
// Now let's see if this function works...
// $output is the array I am sorting
usort($output,"cmp");
What I get is this...
3 Jimmy Chu 23
1 Joe Blow 25
4 Paul Pile 30
2 Jane Doe 5
How can I get this to sort the 'Age' column as numbers...?
Also, I need it in DESC not ASC...
Any help would be awesome...!!!