f::qsort (public)

 f::qsort xs [ value ]

Defined in packages/acs-tcl/tcl/ad-functional-procs.tcl

sorts a sequence with the quicksort algorithm

Parameters:
xs
value (defaults to "id")

Partial Call Graph (max 5 caller/called nodes):
%3 f::head f::head (public) f::tail f::tail (public) f::qsort f::qsort f::qsort->f::head f::qsort->f::tail

Testcases:
No testcase defined.
Source code:
    if { [llength $xs]<2 } { return $xs }
    set pivot [head $xs]
    set big_elmts {}
    set small_elmts {}
    foreach x [tail $xs] {
        if { [$value $x] > [$value $pivot] } {
            lappend big_elmts $x
        } else {
            lappend small_elmts $x
        }
    }
    concat [qsort $small_elmts $value] [list $pivot] [qsort $big_elmts $value]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: