code: public static IsotopePattern sortByMass(IsotopePattern isotopeP) {
          try {
              IsotopePattern isoSort = (IsotopePattern) isotopeP.clone();
              
              // Do nothing for empty isotope pattern
              if (isoSort.getNumberOfIsotopes() == 0) 
                  return isoSort;
  
              // Sort the isotopes
              List<IsotopeContainer> listISO = isoSort.getIsotopes();
              Collections.sort(listISO, new Comparator<IsotopeContainer>() {
                  @Override
                  public int compare(IsotopeContainer o1, IsotopeContainer o2) {
                      return Double.compare(o1.getMass(),o2.getMass());
                  }
              });
             
              // Set the monoisotopic peak to the one with lowest mass
              isoSort.setMonoIsotope(listISO.get(0));
              
              return isoSort;
  
          } catch (CloneNotSupportedException e) {
              e.printStackTrace();
          }
  
          return null;
      }
docs: Return the isotope pattern sorted by mass
  to the highest abundance.
  
  @param isotopeP  The IsotopePattern object to sort
  @return          The IsotopePattern sorted