Skip to content

Instantly share code, notes, and snippets.

@dmacvicar
Created November 9, 2011 22:36
Show Gist options
  • Save dmacvicar/1353367 to your computer and use it in GitHub Desktop.
Save dmacvicar/1353367 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
def sleep_sort(a)
threads = []
a.each do |e|
threads << Thread.new do
sleep e
puts e
end
end
threads.each { |t| t.join }
end
a = [2, 6, 7, 1, 3, 10, 4, 8]
sleep_sort(a)
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment