I have an array of objects Dog. Dog has several fields:
name(String)color(String)kind(String)
If I want to sort the array by name, color, and kind in ascending order, I can do:
dogs.sort_by { |dog| [dog.name, dog.color, dog.kind] }
but what if I want to reverse only by the first field, i.e.,
name(descending)color(ascending)kind(ascending)
Is there any solution without introducing some hash representing color and kind by Intergers (we can apply - to integers when sorting)?