Created
August 30, 2014 11:00
-
-
Save mike-burns/b479d7f0de9e19b7063b 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
def mc_sort(l) | |
a = l.dup | |
while (! sorted?(a)) | |
a.shuffle! | |
end | |
a | |
end | |
def sorted?(l) | |
l.each.with_index do |e, idx| | |
if idx > 0 && l[idx] < l[idx - 1] | |
return false | |
end | |
end | |
true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment