Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

sort numbers in ascending order ruby

result = [41, 9, -9, 2, 31, 32, 12, -1]

result = result.sort { |a, b| a <=> b }

puts result

#OUTPUT: 
-9
-1
2
9
12
31
32
41
 
PREVIOUS NEXT
Tagged: #sort #numbers #ascending #order #ruby
ADD COMMENT
Topic
Name
2+2 =