note 90227 added to function.natcasesort
| From: | Anonymous at osu1 dot php dot net | Date: | Sat, 11 Apr 2009 05:20:04 +0000 |
| Subject: | note 90227 added to function.natcasesort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-153074@lists.php.net to get a copy of this message | ||
The code by claude at schlesser dot lu is quite awkward.
Here is a much simpler solution to sort atwo dimensional array by its keys:
public static function SortByKey($Array)
{
$Keys = array_keys ($Array);
$Values = array_values($Array);
natcasesort($Keys);
$Out = array();
foreach($Keys as $OrgPos => $Key)
{
$Out[$Key] = $Values[$OrgPos];
}
return $Out;
}
----
Server IP: 190.54.16.132
Probable Submitter: 201.246.86.69
----
Manual Page -- http://www.php.net/manual/en/function.natcasesort.php
Edit -- https://master.php.net/note/edit/90227
Del: integrated -- https://master.php.net/note/delete/90227/integrated
Del: useless -- https://master.php.net/note/delete/90227/useless
Del: bad code -- https://master.php.net/note/delete/90227/bad+code
Del: spam -- https://master.php.net/note/delete/90227/spam
Del: non-english -- https://master.php.net/note/delete/90227/non-english
Del: in docs -- https://master.php.net/note/delete/90227/in+docs
Del: other reasons-- https://master.php.net/note/delete/90227
Reject -- https://master.php.net/note/reject/90227
Search -- https://master.php.net/manage/user-notes.php