Program: 108023
Project: 108023
Buggy source:
/** 
 * Returns an ordered list of the distinct set of data items from the given column. This method assumes that the order of string data items can (and should) be derived from the provided hierarchy
 * @param column The column
 * @param hierarchy The hierarchy, may be null
 * @return
 */
public String[] getDistinctValuesOrdered(int column,Hierarchy hierarchy){
  interrupt=false;
  final String[] list=getDistinctValues(column);
  final String attribute=handle.getAttributeName(column);
  final DataType<?> datatype=handle.getDataType(attribute);
  final int level=handle.getGeneralization(attribute);
  final String[][] _hierarchy=hierarchy != null ? hierarchy.getHierarchy() : null;
  if (_hierarchy == null || level == 0) {
    sort(list,datatype,handle.getSuppressionString());
  }
 else {
    final Map<String,Integer> order=new HashMap<String,Integer>();
    int max=0;
    Set<String> baseSet=new HashSet<String>();
    DataType<?> baseType=handle.getBaseDataType(attribute);
    for (int i=0; i < _hierarchy.length; i++) {
      String element=_hierarchy[i][0];
      checkInterrupt();
      if (baseType.isValid(element))       baseSet.add(element);
    }
    String[] baseArray=baseSet.toArray(new String[baseSet.size()]);
    sort(baseArray,handle.getBaseDataType(attribute),handle.getSuppressionString());
    Map<String,Integer> baseOrder=new HashMap<String,Integer>();
    for (int i=0; i < baseArray.length; i++) {
      checkInterrupt();
      baseOrder.put(baseArray[i],i);
    }
    int lower=handle.isOptimized() ? 1 : level;
    int upper=handle.isOptimized() ? _hierarchy[0].length : level + 1;
    for (int i=0; i < _hierarchy.length; i++) {
      checkInterrupt();
      for (int j=lower; j < upper; j++) {
        if (!order.containsKey(_hierarchy[i][j])) {
          Integer position=baseOrder.get(_hierarchy[i][0]);
          if (position != null) {
            order.put(_hierarchy[i][j],position);
            max=Math.max(position,max) + 1;
          }
        }
      }
    }
    String supp=handle.getSuppressionString();
    if (supp != null)     order.put(supp,max);
    sort(list,order);
  }
  return list;
}

Fixed version (ground truth):
/** 
 * Returns an ordered list of the distinct set of data items from the given column. This method assumes that the order of string data items can (and should) be derived from the provided hierarchy
 * @param column The column
 * @param hierarchy The hierarchy, may be null
 * @return
 */
public String[] getDistinctValuesOrdered(int column,String[][] hierarchy){
  interrupt=false;
  final String[] list=getDistinctValues(column);
  final String attribute=handle.getAttributeName(column);
  final DataType<?> datatype=handle.getDataType(attribute);
  final int level=handle.getGeneralization(attribute);
  if (hierarchy == null || level == 0) {
    sort(list,datatype,handle.getSuppressionString());
  }
 else {
    final Map<String,Integer> order=new HashMap<String,Integer>();
    int max=0;
    Set<String> baseSet=new HashSet<String>();
    DataType<?> baseType=handle.getBaseDataType(attribute);
    for (int i=0; i < hierarchy.length; i++) {
      String element=hierarchy[i][0];
      checkInterrupt();
      if (baseType.isValid(element))       baseSet.add(element);
    }
    String[] baseArray=baseSet.toArray(new String[baseSet.size()]);
    sort(baseArray,handle.getBaseDataType(attribute),handle.getSuppressionString());
    Map<String,Integer> baseOrder=new HashMap<String,Integer>();
    for (int i=0; i < baseArray.length; i++) {
      checkInterrupt();
      baseOrder.put(baseArray[i],i);
    }
    int lower=handle.isOptimized() ? 1 : level;
    int upper=handle.isOptimized() ? hierarchy[0].length : level + 1;
    for (int i=0; i < hierarchy.length; i++) {
      checkInterrupt();
      for (int j=lower; j < upper; j++) {
        if (!order.containsKey(hierarchy[i][j])) {
          Integer position=baseOrder.get(hierarchy[i][0]);
          if (position != null) {
            order.put(hierarchy[i][j],position);
            max=Math.max(position,max) + 1;
          }
        }
      }
    }
    String supp=handle.getSuppressionString();
    if (supp != null)     order.put(supp,max);
    sort(list,order);
  }
  return list;
}