A Better Way to Sort Ruby Objects @TestDouble
A Better Way to Sort Ruby Objects  @TestDouble
Uploaded September 2022 | Updated September 2026, 2 weeks ago
Ruby offers a super convenient method for sorting complex objects in Enumerable#sort_by. But when sorting by multiple conditions or dealing with potential nil values, things get messy in a hurry.

This video shows off a common (but little-discussed) technique for building `sort_by` blocks that return prioritized arrays of values and then demonstrates how our new Put gem can accomplish the same thing with a cleaner and more expressive API that provides nil safety.

Check out the Put gem for yourself: github.com/testdouble/put

This video's example code lives here: github.com/testdouble/put_example

Read more about Put at our blog: blog.testdouble.com/talks/2022-09-28-a-better-way-to-sort-ruby-objects

CHAPTERS

00:00 – Introduction

02:10 – Using Enumerable#sort_by with multiple conditions

12:10 – How to use the Put gem
A Better Way to Sort Ruby ObjectsRubyKaigi 2023 - Meet the Organizer, Akira MatsudaConnecting into to Ride with Dave as an urban cyclistYou’re holding it wrong! The double loop model for agentic codingStandard Ruby Update Live StreamHow to ensure product vibes align with real customer needsTaste as the only moatEffective React Testing (Jeremy Fairbank)Secrets of Great Conference Talks - Practical Public Speaking AdviceHow PR Review skills take agentic coding boundaries to the next levelMastering the Macro MachineHow to Program (Justin Searls)
Test Double |

A Better Way to Sort Ruby Objects

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER