NAME
ArrangeDict — Rearrange dict according to list that gives key order.
SYNOPSIS
ArrangeDict DictVariable Arrangement
DESCRIPTION
Return Value
New dict value with entries in order of arrangement.
Arguments
DictVariableDict value to use to make rearranged dict.
ArrangementList with the keys in the order they should in the new dict.
More Info
Elements of the arrangement that are not found in the input dict are ignored. Likewise, elements of the input dict that are not part of the arrangement will not show up in the dict that is returned.

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.


For information regarding exceptions / errors, see here.
EXAMPLES

The following code will :

  1. Create a dictionary.
  2. Print it out to show its original order.
  3. Rearrange it with a call to ArrangeDict.
  4. Print it out to show its new order.

% 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
SEE ALSO
dict
KEYWORDS
arrangement, dict, ordering