Re: Re: array_unique broken?

From: Date: Tue, 03 Sep 2002 08:47:58 +0000
Subject: Re: Re: array_unique broken?
References: 1 2 3 4 5  Groups: php.dev 
Request: Send a blank email to php-dev+get-87860@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: <sebastian@nohn.net>; <php-qa@lists.php.net>; <php-dev@lists.php.net> Sent: Tuesday, September 03, 2002 11:43 AM Subject: Re: [PHP-DEV] Re: [PHP-QA] Re: [PHP-DEV] Re: [PHP-QA] array_unique broken? .... > They are right for current releases, but what is not said is that it's > not obvious what the order will be after sorting, so it's not really > useful to know that the first key for every value is kept. I would say > that the order now is undefined. I think it will be better with the new > code when there is a defined and concistent ordering, and I would say > it's backwards compatible since previously it wasn't defined. > .... > In one way it might make sense to use the systems native sorting functions > when available, they are probably faster. OTOH it might lead to different > sorting on different platforms which is why I say that which key for a > value array_unique() keeps is undefined (except for new implementation). > I would expect mergesort functions to always be stable though, so it might > be safe to use native implementations. > 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). Andrey

« previous php.dev (#87860) next »