note 9170 rejected from function.sort by didou

From: Date: Thu, 23 Oct 2003 16:29:11 +0000
Subject: note 9170 rejected from function.sort by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-59179@lists.php.net to get a copy of this message
Note Submitter: charlie@screaming-penguin.com ---- sort() does not appear to work for arrays that have only a single element. I am using dynamically built arrays and when an array happens to have a single element it does not get touched by sort. Why would I want to sort an array with a single element? Because I want the indeces reset, not just the values sorted. If an array has this structure: array(1) { [3]=> string(9) "Baltimore" then it will not be touched at all by sort and will not be re-indexed to start at 0. To deal with this you can check each dynamically assigned array and count() the elements, if the array has only a single element, then it can be manually re-indexed. This is a work around, but it would be nice if sort would sort single element arrays and or if the manual mentioned this feature-issue.

« previous php.notes (#59179) next »