Voting

: four minus two?
(Example: nine)

The Note You're Voting On

stephen [ at ] brooksie-net [ dot ] co [ dot ] uk
12 years ago
It is obviously 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;

}
?>

<< Back to user notes page

To Top