Sha256: b5e3a10df223255f9d21bd264aac755f8a90dfffd5c5cd2407c18c1ff0ddc388
Contents?: true
Size: 519 Bytes
Versions: 16
Compression:
Stored size: 519 Bytes
Contents
require 'rspec' require 'enumerable_ext' describe Enumerable do describe '#stable_sort' do it 'sorts stably' do xs = [-2, 2, 1, -1] result = xs.stable_sort{|a, b| a.abs <=> b.abs} expected_result = [1, -1, -2, 2] expect(result).to eql expected_result normal_sort_result = xs.sort{|a, b| a.abs <=> b.abs} expect(normal_sort_result).to_not eql expected_result end it 'does not require a block' do expect([3, 2, 1].stable_sort).to eql [1, 2, 3] end end end
Version data entries
16 entries across 16 versions & 1 rubygems