title: How to keep associative array order?
body: <p>I try to iterate over an associative array in Bash.</p>
  
  <p>It seems to be simple, but the loop doesn't follow the initial order of the array.</p>
  
  <p>Here is a simple script to try:</p>
  
  <pre><code>#!/bin/bash
  
  echo -e "Workspace\n----------";
  lsb_release -a
  
  echo -e "\nBash version\n----------";
  echo -e $BASH_VERSION."\n";
  
  declare -A groups;
  groups["group1"]="123";
  groups["group2"]="456";
  groups["group3"]="789";
  groups["group4"]="abc";
  groups["group5"]="def";
  
  echo -e "Result\n----------";
  for i in "${!groups[@]}"
  do
      echo "$i =&gt; ${groups[$i]}";
  done
  </code></pre>
  
  <p>The output:</p>
  
  <pre><code>Workspace
  ----------
  No LSB modules are available.
  Distributor ID: Ubuntu
  Description:    Ubuntu 14.04.2 LTS
  Release:    14.04
  Codename:   trusty
  
  Bash version
  ----------
  4.3.11(1)-release.
  
  Result
  ----------
  group3 =&gt; 789
  group2 =&gt; 456
  group1 =&gt; 123
  group5 =&gt; def
  group4 =&gt; abc
  </code></pre>
  
  <p>Why I don't have <code>group1</code>, <code>group2</code>, etc.?</p>
  
  <p>I don't want to have an alphanum order, I just want that the loop follow the initial declaration's order of the array...</p>
  
  <p>Is there a way?</p>