If you’re working with sorting large data sets in Rails, I’d usually recommend using something like the sorted gem to handle the work for you, but if you’re dealing with relatively small datasets, sometimes it’s just easier to roll your own helper.
I’m currently working on a project in which there are a small number of users in the system. Each has a first name, last name, email, and position column and I wanted to be able to easily sort the columns whenever a user clicks on the column header in each cell.