[Rails] Re: How to perform natural sorting on model and result should be in ActiveRecord::Relation ?
Ruby on Rails
Saturday, February 21, 2015
Found the solution. Change the 'col_name' with your table alphanumeric column name.
-- MyModel.order("LENGTH(col_name)").order(:col_name)
On Saturday, February 21, 2015 at 11:53:30 AM UTC+5:30, Fahim Patel wrote:
On Saturday, February 21, 2015 at 11:53:30 AM UTC+5:30, Fahim Patel wrote:
Hello All,I need to perform natural sorting on alphanumeric column's data and even return type should be ActiveRecord::Relation. I tried 'naturally' and ''naturalsorter'' gem but not successful.Below link explain what is natural sorting.Thanks! in advance
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/426fe208-affd-4941-ae81-7eadfba56379%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment