note 99349 deleted from function.uasort by danbrown

From: Date: Thu, 12 Aug 2010 14:32:00 +0000
Subject: note 99349 deleted from function.uasort by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-171612@lists.php.net to get a copy of this message
Note Submitter: twecsyzenhout at gmail dot com ---- Using usort and strcomp together to order an array by one of its keys has an odd effect: it returns my array with fewer items in it than I put in. The array in my case contains a list of tasks, and I want to order the rows in the array by the field 'displayorder', which is a number but which I want to be sorted in alphabetical manner. function treeSort($a, $b) { return strcmp(strval($a['displayOrder']), strval($b['displayOrder'])); } usort($tree, "treeSort"); There are nine rows, but I only get six of them back. Those six are nicely sorted, by the way.

« previous php.notes (#171612) next »