public static Comparator<SortKey> getComparator(TSDataType dataType, int index, boolean asc) {
    Comparator<SortKey> comparator;
    switch (dataType) {
      case INT32:
      case DATE:
        comparator =
            Comparator.comparingInt(
                (SortKey sortKey) -> sortKey.tsBlock.getColumn(index).getInt(sortKey.rowIndex));
        break;
      case INT64:
      case TIMESTAMP:
        comparator =
            Comparator.comparingLong(
                (SortKey sortKey) -> sortKey.tsBlock.getColumn(index).getLong(sortKey.rowIndex));
        break;
      case FLOAT:
        comparator =
            Comparator.comparingDouble(
                (SortKey sortKey) -> sortKey.tsBlock.getColumn(index).getFloat(sortKey.rowIndex));
        break;
      case DOUBLE:
        comparator =
            Comparator.comparingDouble(
                (SortKey sortKey) -> sortKey.tsBlock.getColumn(index).getDouble(sortKey.rowIndex));
        break;
      case TEXT:
      case BLOB:
      case STRING:
        comparator =
            Comparator.comparing(
                (SortKey sortKey) -> sortKey.tsBlock.getColumn(index).getBinary(sortKey.rowIndex));
        break;
      case BOOLEAN:
        comparator =
            Comparator.comparing(
                (SortKey sortKey) -> sortKey.tsBlock.getColumn(index).getBoolean(sortKey.rowIndex));
        break;
      default:
        throw new IllegalArgumentException("Data type: " + dataType + " cannot be ordered");
    }
    if (!asc) {
      comparator = comparator.reversed();
    }

    return comparator;
  }
-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