Q:

Write a Ruby program to sort a string's characters alphabetically

0

 Write a Ruby program to sort a string's characters alphabetically. 

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

def check_string(str)
   return str.chars.sort.join
end
print check_string("javascript")
print "\n",check_string("python")
print "\n",check_string("PHP")

Output:

aacijprstv
hnopty
HPP

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now