Re: Bug #765: new kusort() function (or similar)
| From: | Zeev Suraski | Date: | Tue, 22 Sep 1998 00:41:24 +0000 |
| Subject: | Re: Bug #765: new kusort() function (or similar) | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-1346@lists.php.net to get a copy of this message | ||
On 22 Sep 1998 libs@cybercable.tm.fr wrote:
> From: libs@cybercable.tm.fr
> Operating system: Linux (irrelevant)
> PHP version: 3.0.3
> PHP Bug Type: Feature/Change Request
> Bug description: new kusort() function (or similar)
>
> I'd be delighted if a new function similar to ksort
> would appear in PHP3.
>
> 1/The requested functionality would be the following one:
> 1.1/Consider an array:
> $toto["001"]="a";
> $toto["010"]="c";
> $toto["100"]="d";
> $toto["002"]="b";
> $toto["110"]="e";
>
> 1.2/Sorting this array on its key with the requested
> function would give:
> key : value
> 001 : a
> 002 : b
> 010 : c
> 100 : d
> 110 : e
>
> 1.3/Due to variable typing, ksort behaves differently
> and sorts this way:
> key : value
> 010 : c
> 100 : d
> 110 : e
> 001 : a
> 002 : b
>
> 1.4/There is no practical way of getting the requested
> functionality with the existing functions.
But there is, exactly this:
> Prepending zero or appending a dot work, of course,
> but it lacks elegance, especially when you have to strip
> the zero or the dot afterwards for use in the rest of
> the script.
I'm not sure that adding specific functions for this fairly rare situation
is more elegant...
Zeev
--
-----------------------------------------------------
Zeev Suraski <zeev@php.net>
For a PGP public key, finger bourbon@netvision.net.il
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net