<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>
<Below this line, add a link to the EXACT exercise that you are stuck at.>
So, below there’s the code that makes the exercise work
```
books.sort! { |first, second| second <=> first }
<do not remove the three backticks above>
I can't understand how. In another post somebody else writes that the result of the comparison is sorted in descending order when the operands are not in the same order as the block parameters.
Pretty straightforward, I get this. But... WHY?
It isn't explained anywhere in the exercise instructions, so I assume I missed something and I should have known this before.
Can anybody explain?
Right, but form what I’ve understood of the comparison operation, it will always tell me (correctly), that 10 is greater than 5.
But switching the operands makes it magically change the sorting order.
Why the switching makes the order to change, that’s what I can’t grasp
I have to say, this lesson does not cover the “why?” of the challenge. I made a simple guess to switch the secondBook and firstBook for the <=> part and got it right on the first try. But I don’t understand why or how that is right.
Tell me where I am going wrong:
If I am comparing 5 to 10, it is going to tell me that 5 is less than 10, so I will put 5 in front of 10.
But if I compare 10 to 5 it is going to tell me that 10 is greater than 5 and will put it behind 5, still making it ascending and not descending order.