From: "byroot (Jean Boussier) via ruby-core" Date: 2026-11-09T07:23:59+00:00 Subject: [ruby-core:127366] [Ruby Misc#22515] Add tests for hash#sort_by Issue #22515 has been updated by byroot (Jean Boussier). Status changed from Open to Rejected Not sure if you intended to link to a patch of some sort but it's not there. Anyway, you are probably best to submit a PR to https://github.com/ruby/spec/ ---------------------------------------- Misc #22515: Add tests for hash#sort_by https://bugs.ruby-lang.org/issues/22515#change-119798 * Author: hdiwan (Hasan Diwan) * Status: Rejected ---------------------------------------- I noticed Hash#sort_by had no test coverage, so I added a few tests for it: ``` ruby def test_sort_by assert_equal({ zebra: 90, apple: 90, banana: 85,c: 3, a: 1, b: 2 }.sort_by { |key, value| [ key, value] }.to_h,{a: 1, apple: 90, b: 2, banana: 85, c: 3, zebra: 90}) assert_equal({ zebra: 90, apple: 90, banana: 85,c: 3, a: 1, b: 2 }.sort_by { |key, value| [value, key] }.to_h, {a: 1, b: 2, c: 3, banana: 85, apple: 90, zebra: 90}) end ``` -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/