+ 2

About sort method

I want to know why following 2 ways to use sort method can reverse the elements in the array "a". a = (1..100).to_a (1) a2 = a.sort{|n1, n2| n2 <=> n1 } p a2 (2) a3 = a.sort_by{|i| -i } p a3 Thank u for ur helping.

15th Jan 2019, 2:58 AM
Yuta Shimizu
Yuta Shimizu - avatar
1 ответ
+ 2
start with shell and bubble sort algoritms
17th Jan 2019, 10:30 AM
Da2
Da2 - avatar
Актуальное сегодня
.
1 Votes
What?
0 Votes
HTML
0 Votes
Web
0 Votes
Quiz duel
0 Votes
FRC Coding?
1 Votes
AI
2 Votes
help
0 Votes
APIs
1 Votes