Module: Enumerable

Defined in:
lib/enumerable.rb

Instance Method Summary collapse

Instance Method Details

#sort_by_alphabet(alphabet) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/enumerable.rb', line 3

def sort_by_alphabet(alphabet)
  if block_given?
    sort{|a, b| yield(a).to_s.compare_by_alphabet(yield(b).to_s, alphabet)}
  else
    sort{|a, b| a.to_s.compare_by_alphabet(b.to_s, alphabet)}
  end
end