Skip to content

Instantly share code, notes, and snippets.

@vindia
Created September 29, 2012 11:41
Show Gist options
  • Save vindia/3803755 to your computer and use it in GitHub Desktop.
Save vindia/3803755 to your computer and use it in GitHub Desktop.
OCDify (set all letters in a word in the correct order)
# Order all letters in a word in a string
#
# Examples:
#
# ocdify('What is the point of this')
# # => 'ahtw is eht inopt fo hist'
#
# Returns the ordered String
def ocdify(string)
a = []
string.downcase.split.each do |word|
a << word.split('').sort.join('')
end
a.join(' ')
end
puts ocdify('What is the point of this')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment