Skip to content

Instantly share code, notes, and snippets.

@greggroth
Created November 10, 2012 20:46
Show Gist options
  • Save greggroth/4052431 to your computer and use it in GitHub Desktop.
Save greggroth/4052431 to your computer and use it in GitHub Desktop.
pry(main)> show-doc Array#sort!
From: array.c (C Method):
Number of lines: 9
Owner: Array
Visibility: public
Signature: sort!()
Sorts self. Comparisons for
the sort will be done using the <=> operator or using
an optional code block. The block implements a comparison between
a and b, returning -1, 0, or +1. See also
Enumerable#sort_by.
a = [ "d", "a", "e", "c", "b" ]
a.sort #=> ["a", "b", "c", "d", "e"]
a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment