> I have a find that look likes this:
>
> @values = UdidValue.find(:all,
>  :conditions => ['udid_id = ?', x.id], :order => 'value ASC')
>
> The problem is that 'value' could be a street address, for example,
> numbers. So, when I do the :order if they are strings the get order
> wonderfully, but in one case I have values that are numbers, for
> example, 234, 233, 219, 25, 199, which get order as 199, 25, 219, 233,
> 234. Which is not what I want. I would like to order as 25, 199, 219,
> 233, 234.
>
> Is there a way to get the order to order properly regardless if it  
> is a
> number of string? Thanks,

Google for "natural sort" for your particular database.

If mysql, maybe... 
http://blog.feedmarker.com/2006/02/01/how-to-do-natural-alpha-numeric-sort-in-mysql/

--~--~---------~--~----~------------~-------~--~----~
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-talk@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