What you have works. Just don’t forget to assign the sorted collection to a variable (sort_by
and reverse
do not change the collection).
Bonus: here’s arguably a nicer version (one pass, instead of two)
a.sort_by{ |v| -v[:a_value] }
solved Multisort using Ruby [closed]