Actions
Misc #22515
closedAdd tests for hash#sort_by
Misc #22515:
Add tests for hash#sort_by
Status:
Rejected
Assignee:
-
Description
I noticed Hash#sort_by had no test coverage, so I added a few tests for it:
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
Actions