Re: Re: array_unique broken?
| From: | Andrey Hristov | Date: | Tue, 03 Sep 2002 09:14:16 +0000 |
| Subject: | Re: Re: array_unique broken? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-87864@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Stig Venaas" <venaas@php.net>
To: "Andrey Hristov" <andrey@webgate.bg>
Cc: <php-dev@lists.php.net>
Sent: Tuesday, September 03, 2002 11:53 AM
Subject: Re: [PHP-DEV] Re: [PHP-QA] Re: [PHP-DEV] Re: [PHP-QA] array_unique
broken?
> On Tue, Sep 03, 2002 at 11:47:58AM +0300, Andrey Hristov wrote:
> > IMO that's good idea to have keys ordered too. All my nightmares with
> > array_diff() came from that
> > the key order is undefined and I tried all kind of tricks (traversing
like
> > in a marathon forward and backwards to
> > find are there couples [k,v] that are identical).
>
> Note that the sorting in array_unique() is just for internal reasons,
> it did until recently determine which key was returned for a value
> though. I think for array_diff() and array_intersect() the ordering
> should be as in the first argument, current implementations do that.
> I don't think any sorting should be done except internally and that
> is just to make things efficient. If we need something like
> array_diff_associative() etc those should also do sorting internally
> for efficiency (I see no other way), and not rely on the unsorted
> output from array_diff() etc.
>
> Stig
>
Yup, I am talking about sorting for internal reasons.
array_diff_assoc(iative)() will share most of the code with array_diff() if
there is
a routine that guaratees that after sorting the keys in equal "value blocks"
will be
also sorted.
Andrey