title: How to clear buffer after sorting method in Java?
body: <p>I have method to sorting elements in Java, it works fine but i need to clear buffer after sorting. It looks like old value stay in buffer and repolace current data and its bad. Can anybody know the solution? <br /></p>
  
  <p>My sorting method: <br /><br /></p>
  
  <pre><code>public List&lt;InterimOrders&gt; getInterimOrdersList() {
  
      if(interimOrdersList == null){
          interimOrdersList = new ArrayList&lt;InterimOrders&gt;();
          interimOrdersList.addAll(interimOrdRepo.findByLocation(location));
  
  
          for(InterimOrders io: interimOrdersList){
  
              if(io.isOnceAMonth()){
                  List&lt;Object[]&gt; tmpList = new ArrayList&lt;Object[]&gt;();
                  long[] datyLongTab = new long[3];
  
                      Object[] tmpOb = new Object[1];
                      tmpOb[0] = (Object)io.getDate1();
  
  
                      if(io.getDate1() != null){
                          datyLongTab[0] =  io.getDate1().getTime();
                      }
                      else{
                          datyLongTab[0] = 9223372036854775807L;
                      }
                      tmpList.add(tmpOb);
  
  
                      tmpOb = new Object[1];
                      tmpOb[0] = (Object)io.getDate2();
  
                      if(io.getDate2() != null){
                          datyLongTab[1] =  io.getDate2().getTime();
                      }
                      else{
                          datyLongTab[1] = 9223372036854775807L;
                      }
                      tmpList.add(tmpOb);
  
  
                      tmpOb = new Object[1];
                      tmpOb[0] = (Object)io.getDate3();
  
  
                      if(io.getDate3() != null){
                          datyLongTab[2] =  io.getDate3().getTime();
                      }
                      else{
                          datyLongTab[2] = 9223372036854775807L;
                      }
                      tmpList.add(tmpOb);
                      Arrays.sort(datyLongTab);  for(int i=0; i&lt;3; i++){
                          long dat = 9223372036854775807L;
                          for(Object[] ele: tmpList){
                               if(ele[0] != null){
                                   dat = ((Date)ele[0]).getTime();
                               }
  
  
                               if(dat==datyLongTab[i]){
  
                                  switch(i){
                                      case 0:
                                          io.setDate1((Date)ele[0]);
  
                                          break;
                                      case 1:
                                          io.setDate2((Date)ele[0]);
  
                                          break;
                                      case 2:
                                          io.setDate3((Date)ele[0]);
  
                                          break; }
  
  
                                  break;
                              }
                          }
  
                      }
  
  
              }return interimOrdersList;
  </code></pre>