Re: [PHP] Sorting times (SOLVED)

2009-05-16 Thread German Geek
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) ==

Re: [PHP] Sorting times (SOLVED)

2009-02-15 Thread tedd
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

Re: [PHP] Sorting times (SOLVED)

2009-02-15 Thread Shawn McKenzie
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

[PHP] Sorting times

2009-02-14 Thread tedd
Hi gang: Anyone have/know a routine that will sort an array of times? For example, a function that would take an array like this: time[0] ~ '1:30pm' time[1] ~ '7:30am' time[2] ~ '12:30pm' and order it to: time[0] ~ '7:30am' time[1] ~ '12:30pm' time[2] ~ '1:30pm' Cheers, tedd -- ---

Re: [PHP] Sorting times

2009-02-14 Thread John Corry
1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com On Feb 14, 2009, at 4:07 PM, tedd wrote: Hi gang: Anyone

Re: [PHP] Sorting times

2009-02-14 Thread Shawn McKenzie
John Corry wrote: 1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com On Feb 14, 2009, at 4:07 PM, tedd

Re: [PHP] Sorting times (SOLVED)

2009-02-14 Thread tedd
At 4:15 PM -0500 2/14/09, John Corry wrote: 1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com John: Bingo -- that

Re: [PHP] Sorting times (SOLVED)

2009-02-14 Thread Shawn McKenzie
tedd wrote: At 4:15 PM -0500 2/14/09, John Corry wrote: 1. convert the string representation of times to timestamps using strtotime() 2. sort the timestamps 3. display the timestamps as strings using date('format', timestamp) Would that work? John Corry email: jco...@gmail.com John: