Program: 37794
Project: 37794
Buggy source:
public List<Site> getAtomsInSphereSorted(final Vect center,double dist){
  List<Site> result=new ArrayList<Site>();
  List<Vect> recipL=this.getRecipLVects();
  List<Double> cFracCoords=center.getComponentsWRTBasis(this.getLatticeVectors());
  int maxx=(int)Math.ceil(cFracCoords.get(0) + dist * recipL.get(0).length() / (2 * Math.PI));
  int minx=(int)Math.floor(cFracCoords.get(0) - dist * recipL.get(0).length() / (2 * Math.PI));
  int maxy=(int)Math.ceil(cFracCoords.get(1) + dist * recipL.get(1).length() / (2 * Math.PI));
  int miny=(int)Math.floor(cFracCoords.get(1) - dist * recipL.get(1).length() / (2 * Math.PI));
  int maxz=(int)Math.ceil(cFracCoords.get(2) + dist * recipL.get(2).length() / (2 * Math.PI));
  int minz=(int)Math.floor(cFracCoords.get(2) - dist * recipL.get(2).length() / (2 * Math.PI));
  for (int i=minx; i <= maxx; i++) {
    for (int j=miny; j <= maxy; j++) {
      for (int k=minz; k <= maxz; k++) {
        for (        Site s : basis) {
          Vect trialCoords=s.getCoords().plus(latticeVectors.get(0).scalarMult((double)i)).plus(latticeVectors.get(1).scalarMult((double)j)).plus(latticeVectors.get(2).scalarMult((double)k));
          if (center.getCartDistanceTo(trialCoords) < dist)           result.add(new Site(s.getElement(),trialCoords));
        }
      }
    }
  }
  Comparator<Site> c=new Comparator<Site>(){
    public int compare(    Site s1,    Site s2){
      if (s1.getCoords().getCartDistanceTo(center) > s2.getCoords().getCartDistanceTo(center))       return 1;
 else       return -1;
    }
  }
;
  Collections.sort(result,c);
  return result;
}

Fixed version (ground truth):
public List<Site> getAtomsInSphereSorted(final Vect center,double dist){
  List<Site> result=new ArrayList<Site>();
  List<Vect> recipL=this.getRecipLVects();
  List<Double> cFracCoords=center.getComponentsWRTBasis(this.getLatticeVectors());
  int maxx=(int)Math.ceil(cFracCoords.get(0) + dist * recipL.get(0).length() / (2 * Math.PI));
  int minx=(int)Math.floor(cFracCoords.get(0) - dist * recipL.get(0).length() / (2 * Math.PI));
  int maxy=(int)Math.ceil(cFracCoords.get(1) + dist * recipL.get(1).length() / (2 * Math.PI));
  int miny=(int)Math.floor(cFracCoords.get(1) - dist * recipL.get(1).length() / (2 * Math.PI));
  int maxz=(int)Math.ceil(cFracCoords.get(2) + dist * recipL.get(2).length() / (2 * Math.PI));
  int minz=(int)Math.floor(cFracCoords.get(2) - dist * recipL.get(2).length() / (2 * Math.PI));
  for (int i=minx; i <= maxx; i++) {
    for (int j=miny; j <= maxy; j++) {
      for (int k=minz; k <= maxz; k++) {
        for (        Site s : basis) {
          Vect trialCoords=s.getCoords().plus(latticeVectors.get(0).scalarMult((double)i)).plus(latticeVectors.get(1).scalarMult((double)j)).plus(latticeVectors.get(2).scalarMult((double)k));
          if (center.getCartDistanceTo(trialCoords) < dist) {
            result.add(s);
            continue;
          }
        }
      }
    }
  }
  Comparator<Site> c=new Comparator<Site>(){
    public int compare(    Site s1,    Site s2){
      if (s1.getCoords().getCartDistanceTo(center) > s2.getCoords().getCartDistanceTo(center))       return 1;
 else       return -1;
    }
  }
;
  Collections.sort(result,c);
  return result;
}