On Sorting in Ruby

After speaking at the Columbus Ruby Brigade last month on the topic of Ruby sorting, I’ve gotten a chance to use some of the sorting techniques I spoke about more over the last month at work. There were a few things I didn’t get a chance to cover since I was only giving a 5-10 minute lightning talk. There’s a few things I’ve come to understand a little better (benefits and gotcha’s) since then.

Things I talked about (feel free to check out the slides from my talk for examples of some of these things)

  • Basic sorting with .sort and .sort!
  • Sorting your own complex types by defining a <=> method on your class
  • Sorting on the fly with blocks
  • Sorting nested objects

Things I did not cover for various reasons. And blog posts covering them in more detail after the fact:

Posted in code. Tags: . Leave a Comment »

Leave a Reply