Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to preserve order of associative array?
- X-seq: zsh-users 20925
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: How to preserve order of associative array?
- Date: Sat, 7 Nov 2015 09:51:40 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern_com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=qGNOs1wPc/ShXLVlZknd2DTrH/ssxAKvYnSy+DNvidI=; b=GtUkuFK70/1U2yFC8BYH0pQHVmFxqfuXx0CqMg2Bqs1bhXJMyQq65TqUx6sspyAjf0 NVBfEji3eB+ko6BUepVDCQy3OyJR333+4VecGCwJDh1n4TxmYOo22N+JWfHEKVuHC4Mz SQ5meIQ7CkY8kCBTUZkVFtcsIhdi0NqOAM/PI2C4Ry3KzycO6jeDVuJFA7TBIYStSrx9 3ro0F1JLyEhML2URtOBrDIpB1jf4sV4hw1RAV3Uhau41cHV4HsifQ17HiI9d81lXdl+V r4ZreSxxeAgrVSMtu1Nqx1hCoU0DVeEjuPtG/UvlOi3PQ9RnhxmTfsFwLOZEsZZG+KD8 hHcg==
- In-reply-to: <CAJjRh0RhVOWz95oCqMuGZ5RMbn39ZpVa3r0KR2cwVqvZ+ChEug@mail.gmail.com>
- 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
- References: <CAJjRh0RhVOWz95oCqMuGZ5RMbn39ZpVa3r0KR2cwVqvZ+ChEug@mail.gmail.com>
On Nov 7, 5:11pm, Dominik Ritter wrote:
}
} I struggle to the order of an associative array right.
Second paragraph in the doc under "Parameters":
The attributes of a parameter determine the _type_ of its value, often
referred to as the parameter type or variable type, and also control
other processing that may be applied to the value when it is referenced.
The value type may be a _scalar_ (a string, an integer, or a floating
point number), an array (indexed numerically), or an _associative_
array (an unordered set of name-value pairs, indexed by name, also
referred to as a _hash_).
You can simulate an ordered set of name-value pairs like this (need zsh
version 5.1 for assigning to an array during typeset):
typeset -a ord_array=(one 1 two 2 three 3 four 4)
print ${ord_array[ord_array[(i)three]+1]}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author