Index: openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl,v diff -u -N -r1.27 -r1.27.2.1 --- openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl 4 Mar 2018 18:40:20 -0000 1.27 +++ openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl 18 Apr 2019 08:02:37 -0000 1.27.2.1 @@ -41,12 +41,21 @@ } OrderedComposite instproc children {} { + if {![info exists :__children]} { + return "" + } set children [expr {[info exists :__children] ? ${:__children} : ""}] if {[info exists :__orderby]} { + if {[llength ${:__children}] > 0} { + set firstChild [lindex ${:__children} 0] + if {![$firstChild exists ${:__orderby}]} { + error "invalid sorting criterion '${:__orderby}'" + } + } set order [expr {[info exists :__order] ? ${:__order} : "increasing"}] - return [lsort -command [list my __compare] -$order $children] + return [lsort -command [list my __compare] -$order ${:__children}] } else { - return $children + return ${:__children} } } OrderedComposite instproc add obj {