On 16 June 2010 15:51, Ants Pants <antsmailingl...@gmail.com> wrote:
> I don't have a problem with comparing floats, but I might need to find the
> 10 closest times to the actual event time and 4 of those times could be less
> than the actual event time and 6 could be higher.

As a starting point, IIWM I would:
  * Get the ten times either side (so I have twenty objects).
  * Calculate the difference of how far each is from the event (ignoring sign)
  * Order the twenty by the difference
  * Take the first ten of them.

With a bit of thought this could all be done in SQL... possibly with a
couple of sub-queries. But it could certainly be stepped through in
Ruby very easily.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to