Re: Sorting Bug / Wrong behavior?

From: Date: Fri, 30 Jul 2004 06:20:46 +0000
Subject: Re: Sorting Bug / Wrong behavior?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-11651@lists.php.net to get a copy of this message
I talked to John about this yesterday. I'll take a closer look at this within the coming days to see if this makes sense and how it affects BC in general (if at all). At 09:45 PM 7/27/2004 +0200, Marcus Boerger wrote:
Hello John, Tuesday, July 27, 2004, 9:48:28 PM, you wrote: Consider the following: <?php $a = array('a', 'b', 'c', 'a'=>0, 'b'=>1, 'c'=>2);
      sort($a);
      print_r($a);
?>> This produces a bogus output: Array (
    [0] => a
    [1] => b
    [2] => 0
    [3] => c
    [4] => 1
    [5] => 2
) Notice how 0 and c are switched incorrectly. Attached is a patch to zend_operators.c that fixes it. The current order simply makes no sense at all.´The following though would: 0 a b c 1 2 // zero dirst, then strings then numbers a b c 0 1 2 // strings first, then numbers 0 1 2 a b c // numbers first, then strings and btw, john you forgot the patch, it is attached here. The one provided does the 2nd which means we only ensured 0 is treated un the same way other numbers are. Best regards,
 Marcus                            mailto:helly@php.net
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.internals (#11651) next »