Sha256: 04f39a710ab94ec612c98e3fb44cf84cfdab82f23d8265fb4e24662c1f8dbfff
Contents?: true
Size: 617 Bytes
Versions: 8
Compression:
Stored size: 617 Bytes
Contents
require 'roqua/core_ext/enumerable/sort_by_alphanum' describe Enumerable do describe '#sort_by_alphanum' do let(:input) { ["004some11thing", "004some10thing", "3another"] } it 'sorts by chunks' do expect(input.sort_by_alphanum).to eq ["3another", "004some10thing", "004some11thing"] end it 'can take a block which can transform values before comparison' do expect(input.sort_by_alphanum(&:reverse)).to eq ["004some10thing", "004some11thing", "3another"] end it 'compares number chunks as integers' do expect(%w(004 3).sort_by_alphanum).to eq %w(3 004) end end end
Version data entries
8 entries across 8 versions & 1 rubygems