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.2.9 -r1.27.2.10 --- openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl 1 Sep 2021 08:14:26 -0000 1.27.2.9 +++ openacs-4/packages/xotcl-core/tcl/20-Ordered-Composite-procs.tcl 7 Sep 2021 14:11:27 -0000 1.27.2.10 @@ -44,20 +44,26 @@ 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 sort_p false + + if {[info exists :__orderby] && [llength ${:__children}] > 0} { + set firstChild [lindex ${:__children} 0] + if {[$firstChild exists ${:__orderby}]} { + set sort_p true + } else { + ad_log warning "invalid sorting criterion '${:__orderby}'" } + } + + if {$sort_p} { set order [expr {[info exists :__order] ? ${:__order} : "increasing"}] return [lsort -command :__compare -$order ${:__children}] } else { return ${:__children} } } + OrderedComposite instproc add obj { lappend :__children $obj $obj set __parent [self]