Register now and start sharing your code snippets.
-->

Sorting an array according to a specific language using Gibberish.

Ruby posted 6 months ago by marko

You can use Ruby’s Enumerable sort_by to sort an array correctly using Gibberish and Gibberish DB

It’s not pretty, but it works on non-paginated lists. For pagination something else must bee cooked up. Here I sort an array of Category objects according to the localized name of the category.

   1  @categories = @categories.sort_by{|a| 
   2        a[:name][].to_s
   3      }

Tagged localized sorting with gibberish