What happens when your code breaks in production? If you have Honeybadger you'll be alerted with crucial details like the error location, the data being processed and the affected users. So you can deploy a fix quickly and get back to coding. Learn more.

RubyFlow The Ruby and Rails community linklog


The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Released the "sorting" gem

The “sorting” gem provides utilities to make sorting with ruby easier.

Installation gem install sorting

Usage require 'sorting/convenience' people.sort_by { |p| [desc(p.first_name), asc(p.age, :nils_last), asc { p.expensive }] }`

As you can see, it allows you to use sort_by to sort by ascending and descending values mixed, deal with potential nils, and performance optimization for expensive sort-values. You can find more examples on the github page.

Future I intend to add natural sorting (for which I already wrote plenty of code, the question is more how to fit it in best API-wise).

Feedback is very welcome!

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in