title: Fastest way to sort and swap elements in Java
body: <p>In Java, I have a list of positive different numbers.</p>
  
  <p>Each number is used as a key in hashsets <code>IntIntHashSet fs</code> and <code>cs</code> used in code below to retrieve some condition values.
  Then I check the condition (if statement) and if true, swap the elements.</p>
  
  <pre><code>int[] list = // given list of positive different ints like [14, 2, 7, 19, 20, 3]
  int l = list.length;
  if (l &gt; 1) {
      int elI, elJ, fI, fJ, swap;
      for (int i = 0; i &lt; l; i++) {
          boolean swapped = false;
          for (int j = 1; j &lt; l; j++) {
              elI = list[j - 1];
              elJ = list[j];
              fI = fs.get(elI);
              fJ = fs.get(elJ);
              if (fI &gt; fJ || (fI == fJ &amp;&amp; cs.get(elI) &gt; cs.get(elJ))) {
                  swap = list[j];
                  list[j] = list[j - 1];
                  list[j - 1] = swap;
                  swapped = true;
              }
          }
          if (!swapped) break;
      }
  }
  </code></pre>
  
  <p>It looks like a <em>Bubble</em> sort, though I'm not very sure. I'm writing a time-consuming program and this part should be optimized as well as possible.</p>
  
  <p>The <strong>main question</strong>: will it be faster to use another sorting approach like <em>QuickSort</em>?</p>
  
  <p>Second question: will it be faster to use <strong>xor</strong> swap method without a temporary variable <code>swap</code>?</p>
  
  <p><strong>[EDIT]</strong>: I might have a very long list containing thousands of numbers. The one above is simple due to example.</p>