Wednesday, August 21, 2013

Coderbyte: Alphabet Soup (Ruby)

PROBLEM

Have the function AlphabetSoup(str) take the str string parameter being passed and return the string with the letters in alphabetical order (ie. hello becomes ehllo). Assume numbers and punctuation symbols will not be included in the string.

SOLUTION

def AlphabetSoup(str)
  return str.split('').sort.join("")       
end
  
print AlphabetSoup(STDIN.gets)