Index: openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl,v diff -u -N -r1.26 -r1.27 --- openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 21 Jan 2003 09:05:59 -0000 1.26 +++ openacs-4/packages/acs-tcl/tcl/utilities-procs.tcl 22 Jan 2003 15:25:07 -0000 1.27 @@ -3019,17 +3019,22 @@ } ad_proc -public util_sets_equal_p { list1 list2 } { - Return 1 if the two lists contain sets of identical items (strings) - (regardless of order) and 0 otherwise. + Tests whether each unique string in list1 occurs as many + times in list1 as in list2 and vice versa (regarless of order). + @return 1 if the lists have identical sets and 0 otherwise + @author Peter Marklund } { if { [llength $list1] != [llength $list2] } { return 0 } - foreach item $list1 { - if { [lsearch -exact $list2 $item] < 0 } { + set sorted_list1 [lsort $list1] + set sorted_list2 [lsort $list2] + + for { set index1 0 } { $index1 < [llength $sorted_list1] } { incr index1 } { + if { ![string equal [lindex $sorted_list1 $index1] [lindex $sorted_list2 $index1]] } { return 0 } }