Bash: iterate over bash array in the order the elements were declared.
|Related pages:||#5431: bash: arrays :-:-: #5481: bash: for ... do iteration|
When I iterate over a map (associative array), the order in which the elements in the array are iterated depend on the type of keys.
If my keys are 1, then 'b' (defined in that order), I get them back in the same order: 1, then 'b'.
If my keys are 1, then 2 (defined in that order), I get them in reverse order: 2, then 1.
This is without changing the for loop, nor changing the order in which the elements are declared, simply changing the keys.
It's the way I iterate over the keys.
They are listed in alphabetical order.
I've spent a few hours trying to understand how to implement bash array indirection.
It's not critical for now, but I wonder which way to have elements iterated over in the same order they were declared.