Great one-liner. This solution has a space complexity of O(n) because an array is allocated. In place sorting solutions can have a space completity of O(1).
That was my first solution, but it does not consider input validation according to description:
"... accepts a string containing up to 26 unique alphabetical characters."
why did you use regxp to evaluate, simple > would be more elegant!
Its grate, but this is not correct solution, instructions where rather clear you shuld accept max 26 caracters. N
"I have developed an elegant solution to this problem."
1 minute later. . .
"Oh, there was already a method for that."
that make sense ;)
I did the same solution, but in addition I've added a regex to evaluate if we are having up to 26 lowercase chars. I think arg validation is important.
This is why Ruby is beautiful.