Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
How to preserve order of associative array?
- X-seq: zsh-users 20918
- From: Dominik Ritter <dritter03@xxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: How to preserve order of associative array?
- Date: Sat, 7 Nov 2015 17:11:14 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=4kDqTwxzCGhv6ZMiGDfLyYUb0zgN69pGin5oaBzpImc=; b=rTyirk68QE/8LgwLeq/MDUIpzNQh2Z8Q4n4R89jjYOktwu/7GcNN9cQTI3aTQoRil0 dUZxodnURi8C3rLC7R+a1JlhQ1f6uYk2KlVEjagnYrLeO+Yxt1Sr+aOzQQ951VpPe8CZ GX+/fjvH6b5q9sub/fOVgEKo1IOyn6M8VlarGV87rfNxp6DUfaUbKhzYF15gE8sRn5r9 DdUMeif/gmDNGPCssZFG4MW2vxkzAXWR7BN2ICak+EzELtDEh17QvMttBXL+wE+p73lb 1a+spb7NYoMm8PvbX8sbKt4qzc0sTBTNdq8dy/npY6qfdDm/VT6h5cxpkYB9jb8uKxlo 4A8w==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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