'''array get''' ''arrayName ?pattern?'' Returns a list containing pairs of elements. The first element in each pair is the name of an element in ''arrayName'' and the second element of each pair is the value of the array element. The order of the pairs is undefined. If ''pattern'' is not specified, then all of the elements of the array are included in the result. If ''pattern'' is specified, then only those elements whose names match ''pattern'' (using the matching rules of '''[string match]''') are included. If ''arrayName'' isn't the name of an array variable, or if the array contains no elements, then an empty list is returned. A very common use for '''array get''' is to wrap an array up and store it as a value (pass it to a command, stick it into another array, or whatever). [array set] will conversely expand the value out into an array again, so that the elements are easily accessable. array set targetArray [array get sourceArray] Of course, as of Tcl 8.5 there is the [dict] command which operates directly on the "wrapped form" of an array. ---- [RR] 12/29/03 It is very likely obvious to even moderately experienced Tcl'rs how to sort the return from "array get" in indexed order but the following might be useful to novices: proc iSort {listin} { foreach {a b} $listin {lappend lout [list $a $b]} return [lsort -index 0 $lout] } The elements of the list returned by "array get", as stated above, alternate between element name and element value in the array. Regardless of the dimension of the array, the element name is a single list element containing the index (like: "0", or "a,b,c", or "month,day"). They come out of "array get" in any and every order imaginable, but always as {elementName elementValue} pairs. To make them more readable, sublist them into those pairs and sort the "super-list" ''[Lars H] 2003-12-30: Modified the code to prevent shimmering (and to some extent garbling) of the data. If the sort key is only part of a list element, then it is usually better to use the -index option than to sort on the whole elements, since the latter forces conversions to string representation.'' ---- See also: * [array] * [array set] * [set] * [dict] ---- [Tcl syntax help] - [Category Command] - [Category Introspection]o