code: public static void sortBy2DDistance(IAtom[] atoms, Point2d point) {
          double distance1;
          double distance2;
          IAtom atom1;
          IAtom atom2;
          boolean doneSomething;
          do {
              doneSomething = false;
              for (int f = 0; f < atoms.length - 1; f++) {
                  atom1 = atoms[f];
                  atom2 = atoms[f + 1];
                  distance1 = point.distance(atom1.getPoint2d());
                  distance2 = point.distance(atom2.getPoint2d());
                  if (distance2 < distance1) {
                      atoms[f] = atom2;
                      atoms[f + 1] = atom1;
                      doneSomething = true;
                  }
              }
          } while (doneSomething);
      }
docs: Sorts a Vector of atoms such that the 2D distances of the atom locations
  from a given point are smallest for the first atoms in the vector.
  See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets
  
  @param  point  The point from which the distances to the atoms are measured
  @param  atoms  The atoms for which the distances to point are measured