Re: Sorting times (SOLVED)

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

 



Just a draft i thought should not go unnoticed on the list :-) just cleaning
up.
OK,

How about a super efficient soln where each string is only converted once
and a fast sorting algorithm is used:

<?php

function time_sort($a, $b)  {
     static $now = time();

     if (strtotime($a, $now) == strtotime($b, $now)) {
         return 0;
     }
     return (strtotime($a, $now) < strtotime($b, $now) ? -1 : 1;
}

function sortTime($times) {

}
Tim-Hinnerk Heuer

http://www.ihostnz.com
Fred Allen  - "California is a fine place to live - if you happen to be an
orange."

2009/2/16 Shawn McKenzie <nospam@xxxxxxxxxxxxx>

> tedd wrote:
> > At 9:31 PM -0600 2/14/09, Shawn McKenzie wrote:
> >>
> >> Yeah, hif I had known that you wanted a function where you loop through
> >> your array twice, that would have done it.  Bravo.
> >
> > Shawn:
> >
> > I don't see another way. You go through the array converting string to
> > time (seconds), sort, and then convert back. You have to go through the
> > array more than once.
> >
> > Cheers,
> >
> > tedd
> >
> The "other way", is the most likely ultra-fast solution I posted.
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> 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