Know what errors lurk in your code? Rollbar detects and alerts you when code breaks in production. Get the stack trace, code, and data to help you d̶e̶b̶u̶g̶ defeat Ruby errors. 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