Ooops, forgot to specify the compare function with usort(); all working now.
Phil. -----Original Message----- From: Phil Ewington - 43 Plc [mailto:[EMAIL PROTECTED] Sent: 22 December 2003 14:08 To: [EMAIL PROTECTED] Subject: [PHP] sorting multi-dimensional arrays Hi All, I am trying to sort a multi-dimensional array using a value in the second dimension. I have looked at the usort examples but don't fully understand what usort is actually doing so am struggling. I have tried the following: if (! getmxrr($this->_Domain, $as_hosts, $ai_weights)) { return false; } for ($i = 0; $i < count($as_hosts); $i++) { $this->MXRecs[] = array($as_hosts[$i], $ai_weights[$i]); } function IsBestMX($a, $b) { if ($a[1] == $b[1]) { return 0; } return ($a[1] < $b[1]) ? -1 : 1; } usort($this->MXRecs); Can anyone point me in the right direction? TIA Phil. --- Phil Ewington - Technical Director 43 Plc - Ashdale House 35 Broad Street, Wokingham Berkshire RG40 1AU T: +44 (0)1189 789 500 F: +44 (0)1189 784 994 E: mailto:[EMAIL PROTECTED] W: www.soyouthink.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php