On Tue, October 31, 2006 11:10 am, Keith Spiller wrote: > RE: Sorting Multidimensional Array > > I'm trying to sort a multidimensional array. The data was taken from > a mysql query: > > $myrow = mysql_fetch_row($result) { > query[] = $myrow; > } > > The purpose is to retrieve the table data and manually add a record, > then sort ASC by the startdate which is the forth field... > > Something like: > > $test = array_multisort($query, $key = '$query[4]'); > > Any help would be greatly appreciated. Thanks, Don't do that. :-) For starters, sorting in PHP is MUCH less efficient than in a DB. Secondly, getting multi-dimensional (sic) arrays in PHP to sort like you want generates a ton of traffic here, so it must be hard. :-) You can do somethig like this: (SELECT x, y, z FROM real_data UNION SELECT 'manually', 'inserted', 'data' as z ) ORDER BY z And achieve MUCH better results with far less headache. If 'z' is indexed in real_data, add another ORDER BY z right before the UNION -- That will probably make it very fast/easy for the DB to splice in your manually-inserted 'z' value. -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php