Re: Sorting Multidimensional Associative arrays

From: Date: Mon, 26 Jun 2000 23:05:50 +0000
Subject: Re: Sorting Multidimensional Associative arrays
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3234@lists.php.net to get a copy of this message
function agesort($a,$b){ if ($a['age']==$b['age']){ return 0; } else{ return ($a['age']<$b['age']) ? 1: -1; } } usort($r,agesort); or something like that. me@artwells.com http://www.artwells.com/ That which indicates nothing introduces everything. On Mon, 26 Jun 2000, Alex V. wrote: > I'm trying to sort a multidimensional asociative array. > > The array looks like this: > > $r[$user]['skill'] > $r[$user]['age'] > $r[$user]['experience'] > > is it possible to sort this array in such way that the first key of it > (user) is the user with the highest age number and the last user is the one > with lowest age number? That is.. an descending sorting of users by their > age. > > If it were a mysql database. what i want is something like "SELECT user FROM > table ORDER BY skill DESC" but since it's an array and not a sql ... I have > no clue :) > > You may ask.. why dont I have that info at an sql so I could make a simple > query... well, I might have some reasons for not doing it. but that's not > the point. so please if anyone knows how to sort the array.. any examples > would be really helpfully :)) > > Thanks in advance > > Alex. > >

« previous php.general (#3234) next »