DictVariable | Dict value to use to make rearranged dict. |
Arrangement | List with the keys in the order they should in the new dict. |
Note that arguments of the form XxxVariable can take either a normal value or the name of a variable to read/write, prefixed by @. See About Using @ for details.
The following code will :
% set MyDict [dict create first one second two third three]
first one second two third three
% # Show original arrangement.
% dict for {Key Value} $MyDict { puts "$Key = $Value" }
first = one
second = two
third = three
% set Rearranged [ArrangeDict $MyDict {three two one}]
% dict for {Key Value} $Rearranged { puts "$Key = $Value" }
third = three
second = two
first = one
% set MyDict [dict create first one second two third three]
first one second two third three
% # Show original arrangement.
% dict for {Key Value} $MyDict { puts "$Key = $Value" }
first = one
second = two
third = three
% ArrangeDict @MyDict {three two one}
% dict for {Key Value} $MyDict { puts "$Key = $Value" }
third = three
second = two
first = one