Can *sort functions return the sorted array ?
| From: | Fulax | Date: | Mon, 25 Oct 2004 12:49:38 +0000 |
| Subject: | Can *sort functions return the sorted array ? | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-13504@lists.php.net to get a copy of this message | ||
Hi,
I wonder if it will be possible to add an extra argument to the *sort functions to get the sorted array directly.
At the moment I have made my own function to do this, here is an example with natsort :
function arrnatsort($a_array)
{
if(natsort($a_array))
return $a_array;else
return false;} I think it will more convenient to simply call $array = natsort($array,true);, when you need to combine functions, like this : $sSortedString = join(',',arrnatsort(explode(',',$sString))); At the moment, the way is to create an auxilliary function, or to make more steps : $aTemArray = explode(',',$sString); natsort($aTempArray); $sSortedString = join(',',$aTempArray); unset $aTempArray; Does it make sense to add the possibility for an extra argument ? Like highlight_string function, the extra argument return the string instead of displaying it. Thanks in advance, and sorry for my crapy English Cyprien