@SuppressWarnings({
    "squid:S3776"
  }) // ignore Cognitive Complexity of methods should not be too high
  public void sortTablet(Tablet tablet) {
    /*
     * following part of code sort the batch data by time,
     * so we can insert continuous data in value list to get a better performance
     */
    // sort to get index, and use index to sort value list
    long[] timestamps = tablet.getTimestamps();
    Object[] values = tablet.getValues();
    BitMap[] bitMaps = tablet.getBitMaps();
    Integer[] index = new Integer[tablet.getRowSize()];
    for (int i = 0; i < tablet.getRowSize(); i++) {
      index[i] = i;
    }
    Arrays.sort(index, Comparator.comparingLong(o -> timestamps[o]));
    Arrays.sort(timestamps, 0, tablet.getRowSize());
    int columnIndex = 0;
    for (int i = 0; i < tablet.getSchemas().size(); i++) {
      IMeasurementSchema schema = tablet.getSchemas().get(i);
      if (schema instanceof MeasurementSchema) {
        values[columnIndex] = sortList(values[columnIndex], schema.getType(), index);
        if (bitMaps != null && bitMaps[columnIndex] != null) {
          bitMaps[columnIndex] = sortBitMap(bitMaps[columnIndex], index);
        }
        columnIndex++;
      } else {
        int measurementSize = schema.getSubMeasurementsList().size();
        for (int j = 0; j < measurementSize; j++) {
          values[columnIndex] =
              sortList(
                  values[columnIndex], schema.getSubMeasurementsTSDataTypeList().get(j), index);
          if (bitMaps != null && bitMaps[columnIndex] != null) {
            bitMaps[columnIndex] = sortBitMap(bitMaps[columnIndex], index);
          }
          columnIndex++;
        }
      }
    }
  }
check whether the batch has been sorted

@return whether the batch has been sorted
iotdb-client/session/src/main/java/org/apache/iotdb/session/Session.java