I have an array that must be sorted with low number to high number and then alphabetical order. Must use Array#sort_by
i_want_dogs = ["I", "want", 5, "dogs", "but", "only", "have", 3]
I want it to output:
=> [3,5,"I","but","dogs","have","only","want"]
I tried:
i_want_dogs.sort_by {|x,y| x <=> y }
I know that is obviously wrong, but I can't figure it out with the integers and the strings combined.
i_want_dogs.sort_by { |x, y| y.to_i <=> x.to_i }should get you pretty close, but the "I" is at the end.