Re: sorting in array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thanks Paul,

  Very weird tried Peter's option, it doesn't work.

  Btw , how to sort by ascending ?

Thanks

Paul Novitski wrote:
At 12:22 AM 7/31/2006, Paul Novitski wrote:
I could make that last statement just a bit simpler:

  function cmpcountry($a, $b)
  {
        $country1 = ($a['country'] == '') ? "zzzzzzz" : $a['country'];
        $country2 = ($b['country'] == '') ? "zzzzzzz" : $b['country'];

        return ($country1 > '' && $country1 < $country2) ? -1 : 1;
  }


*Sigh* I shouldn't post this late at night. This is the comparison function that works for me:

  function cmpcountry($a, $b)
  {
        $country1 = ($a['country'] == '') ? "zzzzzzz" : $a['country'];
        $country2 = ($b['country'] == '') ? "zzzzzzz" : $b['country'];

        return ($country1 < $country2) ? -1 : 1;
  }

demo: http://juniperwebcraft.com/test/sortTest.php
code: http://juniperwebcraft.com/test/sortTest.txt

Paul

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux