Re: Associative array entries order differs from declaration

2019-08-15 Thread Chet Ramey
On 8/15/19 11:26 AM, Léa Gris wrote: > While dealing with getting keys of arrays, I found out that associative > array keys where not registered in the same order as declared: There's no guarantee that will happen. It's a hash table. -- ``The lyf so short, the craft so long to lerne.'' -

Re: Associative array entries order differs from declaration

2019-08-15 Thread Greg Wooledge
On Thu, Aug 15, 2019 at 05:26:03PM +0200, Léa Gris wrote: > Is there a way to control the order of entries in an associative array? No. > What rules applies to the order of entries? None. If you require both an associative array and an ordered list, then you will need two different data

Associative array entries order differs from declaration

2019-08-15 Thread Léa Gris
While dealing with getting keys of arrays, I found out that associative array keys where not registered in the same order as declared: #!/usr/bin/env bash # Declare and populate an associative array a unset a declare -A a=( ["one"]="first" ["two"]="second" ["three"]="third"