Fix the Broken Code

Published by Werdna in

A student learning Ruby was trying to make a function that sorts all the letters of a word, but their code is broken, and they can't figure out why.

Spot and fix the error(s) in the code to make the function work.

Examples

sort_word("dcba") ➞ "abcd"

sort_word("Unpredictable") ➞ "Uabcdeeilnprt"
# Capital letters should come first.

sort_word("pneumonoultramicroscopicsilicovolcanoconiosis") ➞ "aacccccceiiiiiilllmmnnnnooooooooopprrsssstuuv"

Notes

N/A

Watch a quick demo on how Edabit works.