Module: SortByAlphabet::InstanceMethods
- Defined in:
- lib/sort_by_alphabet.rb
Instance Method Summary collapse
Instance Method Details
#compare_by_alphabet(other, alphabet) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/sort_by_alphabet.rb', line 5 def compare_by_alphabet(other, alphabet) l1 = self.mb_chars.length l2 = other.mb_chars.length (0...[l1, l2].min).each do |i| c = alphabet.compare_letters(self.mb_chars[i..i], other.mb_chars[i..i]) return c unless c == 0 end l1 <=> l2 end |