Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

How to preserve order of associative array?



Hi everyone!

I struggle to the order of an associative array right. If I take the
example from zsh-lovers man page:

    $ typeset -A ass_array; ass_array=(one 1 two 2 three 3 four 4)
    $ print ${(k)ass_array} # prints keys
    one four two three
    $ print ${(v)ass_array} # prints values
    1 4 2 3

I would expect that to be the keys sorted as they appear in the array
(one, two, three, four).

I tried to sort them in array index order, but without luck:
print ${(ak)ass_array}

The other sort-modifiers won't help me, as I need a hierarchy in my
array keys (neither lexically, nor numerical).

Thanks for any help. Regards,
Dominik



Messages sorted by: Reverse Date, Date, Thread, Author