Ruby Sort Array

[Solved] Ruby Sort Array | Haskell - Code Explorer | yomemimo.com
Question : rails array sort

Answered by : benedict-ouma

array.sort

Source : | Last Update : Tue, 03 May 22

Question : ruby sort array numerically

Answered by : beautiful-bear-jwxgx4frys32

a.sort_by(&:to_i)

Source : https://stackoverflow.com/questions/7726968/sort-an-array-of-strings-by-their-integer-values/7727416 | Last Update : Tue, 22 Dec 20

Question : ruby sort array numerically

Answered by : beautiful-bear-jwxgx4frys32

a = ["teste", "test", "teste2", "tes3te", "10teste"]
a.sort_by! {|s| s[/\d+/].to_i}

Source : https://stackoverflow.com/questions/7726968/sort-an-array-of-strings-by-their-integer-values/7727416 | Last Update : Tue, 22 Dec 20

Answers related to ruby sort array

Code Explorer Popular Question For Haskell