Created
June 23, 2015 14:41
-
-
Save 284km/96d98734708b944da277 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
def sorted? | |
return true if self.size < 2 | |
1.upto(self.size - 1) do |i| | |
return false unless self[i - 1] <= self[i] | |
end | |
true | |
end | |
end | |
a = [1, 2, 3, 4] | |
puts a.shuffle!.inspect | |
until a.sorted? | |
puts a.shuffle!.inspect | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment