KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am having a problem understanding how array.sort{ |x,y| block } works exactly, hence how to use it? An example from Ruby documentation : a = [ "d", "a", "e", "c", "b" ] a.sort #=> ["a", "b", "c", "d", "e"] a.sort { |x,y| y <=> x } #=> ["e", "d", "c", "b", "a"]
Tags (comma-separated)
Save Edits
Cancel