title: java merge sorting arrays with objects
body: <p>I couldn't figure out why my merge sort isn't working.</p>
  <pre><code>public static void merge(ArrayList&lt;Coupon&gt; arraylist, int LF, int LL, int RF, int RL) {
          ArrayList&lt;Coupon&gt; tempArr = arraylist;
          int i = LF;
          while (LF &lt;= LL &amp;&amp; RF &lt;= RL) {
              if (arraylist.get(LF).getPrice() &lt; arraylist.get(RF).getPrice()) {
                  tempArr.Swap(i, LF);
                  LF++;   
              } else {
                  tempArr.Swap(i, RF);;
                  RF++;
              }
              i++;
          }
          while (LF &lt;= LL) {
              tempArr.Swap(i, LF);
              LF++;
              i++;
          }
          while (RF &lt;= RL) {
              tempArr.Swap(i, RF);
              RF++;
              i++;
          }
          arraylist = tempArr;
      }
      
      public static void mergeSort(ArrayList&lt;Coupon&gt; arraylist, int first, int last) {
          if (first &lt; last) {
              int middle = (first + last) / 2;
              mergeSort(arraylist, first, middle);
              mergeSort(arraylist, middle + 1, last);
              merge(arraylist, first, middle, middle+1, last);
          }
      }
  </code></pre>
  <p>I made sure I used it in my main class with correct parameters, I made sure the code actually looped through all the while loops and if-else statements(I checked with system out print in each statement), I also made sure that my Swap method is working by using it elsewhere. Can you help me find what went wrong? Thank you so much in advance!</p>
  <p>P.S. LF is left first, LL is left last, RF is right first, RL is right last.</p>