From: sawadatsuyoshi@... Date: 2016-03-27T08:24:05+00:00 Subject: [ruby-core:74604] [Ruby trunk Bug#12221] Enumerable#sort_by method doesn't work properly when the array has more than 6 elements and you pass nil to the block Issue #12221 has been updated by Tsuyoshi Sawada. What is wrong with it? ---------------------------------------- Bug #12221: Enumerable#sort_by method doesn't work properly when the array has more than 6 elements and you pass nil to the block https://bugs.ruby-lang.org/issues/12221#change-57731 * Author: Lucas Caton * Status: Open * Priority: Normal * Assignee: * ruby -v: ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15] * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- ~~~ %w(1 2).sort_by { |i| nil } # => ["1", "2"] # ... %w(1 2 3 4 5 6).sort_by { |i| nil } # => ["1", "2", "3", "4", "5", "6"] ~~~ So far, so good... But look what happens when you have 7 or more elements: ~~~ %w(1 2 3 4 5 6 7).sort_by { |i| nil } # => ["4", "2", "3", "1", "5", "6", "7"] %w(1 2 3 4 5 6 7 8).sort_by { |i| nil } # => ["8", "2", "3", "4", "5", "6", "7", "1"] %w(1 2 3 4 5 6 7 8 9).sort_by { |i| nil } # => ["9", "2", "3", "4", "5", "6", "7", "8", "1"] %w(1 2 3 4 5 6 7 8 9 10).sort_by { |i| nil } # => ["10", "2", "3", "4", "5", "6", "7", "8", "9", "1"] ~~~ -- https://bugs.ruby-lang.org/ Unsubscribe: