- Subject: Re: [slang-users] iterate the elements of an assoc_array in sorted order
- From: "John E. Davis" <davis@xxxxxxxxxxxxx>
- Date: Sat, 3 Jun 2006 18:57:16 -0400
Jörg Sommer <joerg@xxxxxxxxxxxx> wrote:
>how is it possible to iterate through an Assoc_Array in sorted order.
>This is ugly:
>
>foreach ( assoc_get_keys(templates)[array_sort(assoc_get_keys(templates))] )
You will have to perform a sort as you have done. I would write the
above as
keys = assoc_get_keys (templates);
foreach k (keys[array_sort(keys)]) {...}
which I find somewhat more readable.
--John
_______________________________________________
To unsubscribe, visit http://jedsoft.org/slang/mailinglists.html
[2006 date index]
[2006 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]