Skip to content

Instantly share code, notes, and snippets.

@mike-burns
Created August 30, 2014 11:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mike-burns/b479d7f0de9e19b7063b to your computer and use it in GitHub Desktop.
Save mike-burns/b479d7f0de9e19b7063b to your computer and use it in GitHub Desktop.
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