Program: 11037
Project: 11037
Buggy source:
protected void sortIndices(DrawContext dc,Vec4 eyePoint,float[] vertices,int[] indices,int[] sortedIndices){
  int size=vertices.length / 3;
  Vec4[] verts=new Vec4[size];
  for (int i=0, j=0; i < vertices.length; i+=3, j++) {
    verts[j]=new Vec4(vertices[i + 0],vertices[i + 1],vertices[i + 2]);
  }
  eyePoint=eyePoint.subtract3(boundingSphere.getCenter());
  if (mode == GL.GL_TRIANGLES) {
    boolean hasIndices=indices != null;
    int triangleCountBy3=hasIndices ? indices.length : size;
    IndexAndDistance[] distances=new IndexAndDistance[triangleCountBy3 / 3];
    for (int i=0, j=0; i < triangleCountBy3; i+=3, j++) {
      int index0=hasIndices ? indices[i + 0] : i + 0;
      int index1=hasIndices ? indices[i + 1] : i + 1;
      int index2=hasIndices ? indices[i + 2] : i + 2;
      Vec4 v0=verts[index0];
      Vec4 v1=verts[index1];
      Vec4 v2=verts[index2];
      double distance=v0.distanceToSquared3(eyePoint) + v1.distanceToSquared3(eyePoint) + v2.distanceToSquared3(eyePoint);
      distances[j]=new IndexAndDistance(distance,i);
    }
    Arrays.sort(distances);
    IndexAndDistance closest=distances[distances.length - 1];
    Vec4 closestPoint=verts[hasIndices ? indices[closest.index] : closest.index];
    distanceFromEye=closestPoint.distanceTo3(eyePoint);
    for (int i=0, j=0; i < triangleCountBy3; i+=3, j++) {
      IndexAndDistance distance=distances[j];
      sortedIndices[i + 0]=hasIndices ? indices[distance.index + 0] : distance.index + 0;
      sortedIndices[i + 1]=hasIndices ? indices[distance.index + 1] : distance.index + 1;
      sortedIndices[i + 2]=hasIndices ? indices[distance.index + 2] : distance.index + 2;
    }
  }
 else   if (mode == GL.GL_POINTS) {
    IndexAndDistance[] distances=new IndexAndDistance[size];
    for (int i=0; i < size; i++) {
      double distance=verts[i].distanceToSquared3(eyePoint);
      distances[i]=new IndexAndDistance(distance,i);
    }
    Arrays.sort(distances);
    IndexAndDistance closest=distances[distances.length - 1];
    Vec4 closestPoint=verts[closest.index];
    distanceFromEye=closestPoint.distanceTo3(eyePoint);
    for (int i=0; i < size; i++) {
      sortedIndices[i]=distances[i].index;
    }
  }
}

Fixed version (ground truth):
protected void sortIndices(DrawContext dc,Vec4 eyePoint,float[] vertices,int[] indices,int[] sortedIndices){
  int size=vertices.length / 3;
  Vec4[] verts=new Vec4[size];
  for (int i=0, j=0; i < vertices.length; i+=3, j++) {
    verts[j]=new Vec4(vertices[i + 0],vertices[i + 1],vertices[i + 2]);
  }
  if (boundingSphere != null)   eyePoint=eyePoint.subtract3(boundingSphere.getCenter());
  if (mode == GL.GL_TRIANGLES) {
    boolean hasIndices=indices != null;
    int triangleCountBy3=hasIndices ? indices.length : size;
    IndexAndDistance[] distances=new IndexAndDistance[triangleCountBy3 / 3];
    for (int i=0, j=0; i < triangleCountBy3; i+=3, j++) {
      int index0=hasIndices ? indices[i + 0] : i + 0;
      int index1=hasIndices ? indices[i + 1] : i + 1;
      int index2=hasIndices ? indices[i + 2] : i + 2;
      Vec4 v0=verts[index0];
      Vec4 v1=verts[index1];
      Vec4 v2=verts[index2];
      double distance=v0.distanceToSquared3(eyePoint) + v1.distanceToSquared3(eyePoint) + v2.distanceToSquared3(eyePoint);
      distances[j]=new IndexAndDistance(distance,i);
    }
    Arrays.sort(distances);
    IndexAndDistance closest=distances[distances.length - 1];
    Vec4 closestPoint=verts[hasIndices ? indices[closest.index] : closest.index];
    distanceFromEye=closestPoint.distanceTo3(eyePoint);
    for (int i=0, j=0; i < triangleCountBy3; i+=3, j++) {
      IndexAndDistance distance=distances[j];
      sortedIndices[i + 0]=hasIndices ? indices[distance.index + 0] : distance.index + 0;
      sortedIndices[i + 1]=hasIndices ? indices[distance.index + 1] : distance.index + 1;
      sortedIndices[i + 2]=hasIndices ? indices[distance.index + 2] : distance.index + 2;
    }
  }
 else   if (mode == GL.GL_POINTS) {
    IndexAndDistance[] distances=new IndexAndDistance[size];
    for (int i=0; i < size; i++) {
      double distance=verts[i].distanceToSquared3(eyePoint);
      distances[i]=new IndexAndDistance(distance,i);
    }
    Arrays.sort(distances);
    IndexAndDistance closest=distances[distances.length - 1];
    Vec4 closestPoint=verts[closest.index];
    distanceFromEye=closestPoint.distanceTo3(eyePoint);
    for (int i=0; i < size; i++) {
      sortedIndices[i]=distances[i].index;
    }
  }
}