Skip to content

Instantly share code, notes, and snippets.

@noctivityinc
Last active August 29, 2015 14:03
Show Gist options
  • Save noctivityinc/7b8e727d6e0792a4bd3c to your computer and use it in GitHub Desktop.
Save noctivityinc/7b8e727d6e0792a4bd3c to your computer and use it in GitHub Desktop.
to_pseudo_number.rb
class String
def to_pseudo_number
return if self.nil?
self.split(//).inject([]) {|num, x| num << x.ord}.join().to_i
end
end
class Array
def sort_letters
self.sort {|a,b| a.to_pseudo_number <=> b.to_pseudo_number}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment