i have an array with numbers like this:
list1 = [50, 2, 99, 1, 958, 9, 6, 80]
and i need to compare all elements: digit by digit. for exemple, it will be important to compare "9", "99" and "958", because i'll need to put "99" at the end like this:
list1 = [1, 2, 50, 6, 80, 9, 958, 99]
Does Ruby has a function for this? thank you very much for your help :)
list1.map(&:to_s).sortto convert to strings and that sorts it like what I think you're asking, but your 2nd example doesn't have the first half of your list sorted (e.g. why does 50 sort before 2?)