This is probably more of a Ruby question than a RoR question.
I need to sort an array of objects in descending order based on a
specific attribute. Sorting as follows results in an ascending order:
@items.sort! { |item1, item2|
item1.value_total <=> item2.value_total}
To order descending, I need to then:
@items.reverse!
I’m wondering if there is an operator similar to <=> that would result
in the reverse order? It seems a different operator could net a more
efficient algorithm. Or perhaps reverse is not an intensive activity?