I want to sort this array by two different conditionals.
First I want to sort the array by type: A type can be either (1,2,3,4) and I want to sort them in this order 4 - 1 - 2 - 3.
Then within each different type I want to sort them by a percentage descending.
So a sorted array would look like this:
[
<OpenStruct percent=70, type=4>,
<OpenStruct percent=60, type=4>,
<OpenStruct percent=50, type=4>,
<OpenStruct percent=73, type=1>,
<OpenStruct percent=64, type=1>,
<OpenStruct percent=74, type=2>
]ect
How can I accomplish this sort? Currently I can only sort by type descending.
array = array.sort_by {|r| r.type }