On 10/03/2017 06:54, Juge wrote:
> Is there a way of putting this in a one liner - I imagined that using
> regexp and inline option I might get there, but so far I got
> nowhere.
The best thing is to use the optional filtering argument to [array
names], which takes a standard glob pattern, and then [lsort
-dictionary] to order the result (which is an ordering designed to “do
the right thing” in a lot of common cases; it sorts digit sequences as
numbers and the rest according to standard letter rules). With just two
commands required to do all the work, making a one-liner is simple.
set page 2
set keys [lsort -dictionary [array names myArr p${page}w*]]
Donal.
--
Donal Fellows — Tcl user, Tcl maintainer, TIP editor.