How to perform natural sorting on model and result should be in ActiveRecord::Relation?

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

Found the solution. Change the ‘col_name’ with your table alphanumeric
column name.

MyModel.order(“LENGTH(col_name)”).order(:col_name)