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.

http://www.copterlabs.com/blog/natural-sorting-in-mysql/

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/ca6a9014-79dc-4b4d-98a4-f197dd3e3d19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Fahim Patel at Feb 21, 2015 at 6:23 am
    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.

    http://www.copterlabs.com/blog/natural-sorting-in-mysql/

    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/45bac468-520a-47dc-906a-7af80b53ebd9%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Fahim Patel at Feb 21, 2015 at 10:08 am
    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:

    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.

    http://www.copterlabs.com/blog/natural-sorting-in-mysql/

    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedFeb 21, '15 at 6:23a
activeFeb 21, '15 at 10:08a
posts3
users1
websiterubyonrails.org
irc#RubyOnRails

1 user in discussion

Fahim Patel: 3 posts

People

Translate

site design / logo © 2021 Grokbase