public static Comparator<SortKey> getComparator(
      List<SortItem> sortItemList, List<Integer> indexList, List<TSDataType> dataTypeList) {

    // use code-gen compile this comparator
    List<Comparator<SortKey>> list = new ArrayList<>(indexList.size());
    for (int i = 0; i < indexList.size(); i++) {
      int index = indexList.get(i);
      if (index == -2) {
        continue;
      }
      TSDataType dataType = dataTypeList.get(i);
      boolean asc = sortItemList.get(i).getOrdering() == Ordering.ASC;
      boolean nullFirst = sortItemList.get(i).getNullOrdering() == NullOrdering.FIRST;
      list.add(genSingleComparator(asc, index, dataType, nullFirst));
    }

    return list.size() == 1 ? list.get(0) : new ComparatorChain<>(list);
  }
-1 in index is for time column.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/MergeSortComparator.java