Posted to tcl by dbohdan at Tue Mar 26 09:18:25 GMT 2019view raw

  1. proc sleepsort intlist {
  2. set ::result {}
  3. set ::count 0
  4.  
  5. foreach n $intlist {
  6. after $n [list apply {n {
  7. lappend ::result $n
  8. incr ::count
  9. }} $n]
  10. }
  11.  
  12. while {$::count < [llength $intlist]} {
  13. vwait ::count
  14. }
  15.  
  16. return $::result
  17. }
  18.