title: How to add values beside elements in an array in bubble sort algorithm in java
body: <p>Hi I have the following bubble sort algorithm (generic code taken from another site) and I would like to have numbers next to each element of the array as it gets sorted. For example when I run it and it sorts out the array, next to each element it should have the number 1 as this is the first of many sorting algorithms I am using. So to demonstrate:
  My results after sorting will look like:</p>
  
  <pre><code>4 1
  27 1
  54 1
  321 1
  542 1
  654 1
  887 1
  1023 1
  </code></pre>
  
  <p>As you can see, the number 1 is inserted into the each element of the array as it is being sorted in the algorithm. Can someone help me with this?</p>
  
  <p>Sorting algorithm:</p>
  
  <pre class="lang-java prettyprint-override"><code>public static &lt;E extends Comparable&lt;? super E&gt;&gt; void bubbleSort(E[] comparable) {
      boolean changed = false;
      do {
          changed = false;
          for (int a = 0; a &lt; comparable.length - 1; a++) {
              if (comparable[a].compareTo(comparable[a + 1]) &gt; 0) {
                  E tmp = comparable[a];
                  comparable[a] = comparable[a + 1];
                  comparable[a + 1] = tmp;
                  changed = true;
              }
          }
      } while (changed);
  }
  </code></pre>