Skip to content

Instantly share code, notes, and snippets.

@DonSchado
Created October 26, 2011 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DonSchado/1317179 to your computer and use it in GitHub Desktop.
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".
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