Module: Enumerable

Defined in:
lib/roqua/core_ext/enumerable/sort_by_alphanum.rb

Instance Method Summary collapse

Instance Method Details

#sort_by_alphanumObject



2
3
4
5
6
7
8
9
10
# File 'lib/roqua/core_ext/enumerable/sort_by_alphanum.rb', line 2

def sort_by_alphanum
  sort do |a, b|
    if block_given?
      grouped_compare(yield(a), yield(b))
    else
      grouped_compare(a, b)
    end
  end
end

#sort_by_alphanum!Object



12
13
14
15
16
17
18
19
20
# File 'lib/roqua/core_ext/enumerable/sort_by_alphanum.rb', line 12

def sort_by_alphanum!
  sort! do |a, b|
    if block_given?
      grouped_compare(yield(a), yield(b))
    else
      grouped_compare(a, b)
    end
  end
end