Sha256: 028db18a589b3de409eda515da949ae26cab1ee99167c25652f1ef8015f50543

Contents?: true

Size: 302 Bytes

Versions: 5

Compression:

Stored size: 302 Bytes

Contents

module Enumerable

  def natural_sort
    natural_sort_by
  end

  def natural_sort_by(&stringifier)
    sort_by do |element|
      element = stringifier.call(element) if stringifier
      element = element.to_s unless element.respond_to?(:to_sort_atoms)
      element.to_sort_atoms
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
katapult-0.5.0 lib/generators/katapult/basics/templates/lib/ext/enumerable/natural_sort.rb
katapult-0.4.1 lib/generators/katapult/basics/templates/lib/ext/enumerable/natural_sort.rb
katapult-0.4.0 lib/generators/katapult/basics/templates/lib/ext/enumerable/natural_sort.rb
katapult-0.3.0 lib/generators/katapult/basics/templates/lib/ext/enumerable/natural_sort.rb
katapult-0.2.0 lib/generators/katapult/basics/templates/lib/ext/enumerable/natural_sort.rb