If I have a string array that looks like this:
array = ["STRING1", "STRING05", "STRING20", "STRING4", "STRING3"]
or
array = ["STRING: 1", "STRING: 05", "STRING: 20", "STRING: 4", "STRING: 3"]
How can I sort the array by the number in each string (descending)?
I know that If the array consisted of integers and not strings, I could use:
sort_by { |k, v| -k }
I've searched all around but can't come up with a solution
array.sort_by(&:reverse).reversealso works.