I'm just trying to sort my strings alphabetically but while maintaining their position inside an array. For example, I have :
myArray = ["tree", "house", "show", "merit", "timer"]
and I'd like to perform an each loop on it in order to output :
myArray = ["eert", "ehosu", "hosw", and so on...]
I wanted to do something like this :
myArray.each do |x|
x.chars.sort.join
end
For a single string that works but I guess "chars" doesn't work for multiple strings in an array. Or maybe it does and I'm not doing it right. Basically how would I modify it in order to get that output?