Created
October 26, 2011 18:05
-
-
Save DonSchado/1317179 to your computer and use it in GitHub Desktop.
Given a string "Sort words in a sentence", it should return "a in Sort words sentence".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sort_string(string) | |
string.split(' ').sort{|x, y| x.length <=> y.length}.join(' ') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment