code: public static void sort(IAtomContainerSet atomContainerSet) {
          List<IAtomContainer> atomContainerList = AtomContainerSetManipulator.getAllAtomContainers(atomContainerSet);
          Collections.sort(atomContainerList, new AtomContainerComparator());
          atomContainerSet.removeAllAtomContainers();
          for (Object anAtomContainerList : atomContainerList)
              atomContainerSet.addAtomContainer((IAtomContainer) anAtomContainerList);
      }
  
      /**
       * Tells if an AtomContainerSet contains at least one AtomContainer with the
       * same ID as atomContainer. Note this checks getID() for equality, not pointers.
       *
       * @param id The IAtomContainer to look for
       * @param atomContainerSet The collection of IAtomContainer objects
       */
      public static boolean containsByID(IAtomContainerSet atomContainerSet, String id) {
          for (IAtomContainer ac : atomContainerSet.atomContainers()) {
              if (ac.getID() != null && ac.getID().equals(id)) return true;
          }
          return false;
      }
docs: <p>Sorts the IAtomContainers in the given IAtomContainerSet by the following
  criteria with decreasing priority:</p>
  <ul>
  <li>Compare atom count
  <li>Compare molecular weight (heavy atoms only)
  <li>Compare bond count
  <li>Compare sum of bond orders (heavy atoms only)
  </ul>
  <p>If no difference can be found with the above criteria, the IAtomContainers are
  considered equal.</p>
  @param atomContainerSet The collection of IAtomContainer objects