note 111537 added to function.asort

From: Date: Fri, 01 Mar 2013 16:37:07 +0000
Subject: note 111537 added to function.asort
Groups: php.notes 
Request: Send a blank email to php-notes+get-193768@lists.php.net to get a copy of this message
Update to previous post, it is obviously also necessary to log the keys used as so we don't overwrite previous entries in the array ;o) N.B. this also effects the timings, but still faster than the alternatives : * int : 0.00159 (ms) * str : 0.00092 (ms) <?php private function _keySort(Array $data) { $keys = array(); foreach($data as $row) { $keyIncrement = (!isset($keys[$row[$this->_orderField]])) ? $keys[$row[$this->_orderField]] = 0 : ++$keys[$row[$this->_orderField]]; $tempArray[$row[$this->_orderField].$keyIncrement] = $row; } if ($this->_orderDirection == 'DESC') { krsort($tempArray, SORT_NATURAL | SORT_FLAG_CASE ); } else { ksort($tempArray, SORT_NATURAL | SORT_FLAG_CASE); } return $tempArray; } ?> ---- Server IP: 69.147.83.199 Probable Submitter: 82.136.45.164 ---- Manual Page -- http://php.net/manual/en/function.asort.php Edit -- https://master.php.net/note/edit/111537 Del: integrated -- https://master.php.net/note/delete/111537/integrated Del: useless -- https://master.php.net/note/delete/111537/useless Del: bad code -- https://master.php.net/note/delete/111537/bad+code Del: spam -- https://master.php.net/note/delete/111537/spam Del: non-english -- https://master.php.net/note/delete/111537/non-english Del: in docs -- https://master.php.net/note/delete/111537/in+docs Del: other reasons-- https://master.php.net/note/delete/111537 Reject -- https://master.php.net/note/reject/111537 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#193768) next »