You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
416 B
17 lines
416 B
#testing. |
|
|
|
|
|
|
|
proc quicksort {m} { |
|
if {[llength $m] <= 1} { |
|
return $m |
|
} |
|
set pivot [lindex $m 0] |
|
set less [set equal [set greater [list]]] |
|
foreach x $m { |
|
lappend [expr {$x < $pivot ? "less" : $x > $pivot ? "greater" : "equal"}] $x |
|
} |
|
return [concat [quicksort $less] $equal [quicksort $greater]] |
|
} |
|
|
|
puts [quicksort {8 6 4 2 1 3 5 7 9}] ;# => 1 2 3 4 5 6 7 8 9 |