code: @Override
      public int compare(IAtomContainer a, IAtomContainer b) {
  
          Point2d p1 = center(a);
          Point2d p2 = center(b);
  
          if (p1.x > p2.x) return +1;
          if (p1.x < p2.x) return -1;
          if (p1.y > p2.y) return +1;
          if (p1.y < p2.y) return -1;
  
          return 0;
  
      }
docs: Compare two AtomContainers based on their 2D position.
  @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)