array sort ruby code example
Example 1: ruby sort array numerically
a.sort_by(&:to_i)
Example 2: ruby sort array numerically
a = ["teste", "test", "teste2", "tes3te", "10teste"]
a.sort_by! {|s| s[/\d+/].to_i}
Example 3: ruby sort method
numbers = [5,3,2,1]
numbers.sort
# [1,2,3,5]