From: KATO K. <k.k...@gm...> - 2008-05-26 19:12:44
|
2008/5/27, Jeff Hobbs: > Yes, tcl8.5/tests/dict.test, look for use of "getOrder". (1)sorted a dict order by argment, and [lappend [dict size $dict]. 2008/5/27, Andreas Kupries: > Tcllib's testsuite support code contains a command 'dictsort' which sorts a > dictionary by keys > > The definition is in Tcllib's file modules/devtools/testutilities.tcl, (2)sorted a dict order by alphabetical one. 1,2, All could be used for evaluation of a value by a future test. Thank you for teaching. By for the moment, although the difference is absorbed reflecting the action of [dict create] in all values, it may be one with better using these helpers in fact. > If you are talking about Tcl 8.5's dict structre and command, then no, IIRC > the ordering of keys is preserved by them (append order). To be sure, such an action was able to be checked. It did not know that it was decided as specification. However, dict-extension in Tcl8.4 has not adopted such how to move. > > # remove duplications with saving key order > > proc ::yaml::_remove_duplication {dict} { > > array set tmp $dict > > array set tmp2 {} > > foreach {key nop} $dict { > > if [info exists tmp2($key)] continue > > lappend result $key $tmp($key) > > lappend result $key $nop > and the array 'tmp' is not required. > > > set tmp2($key) 1 > > } > > return $result > > } Then, it does not become operation whose intention it has. 'key' is the given order and 'value' wants to evaluate the last thing. |