public int countRunAndMakeAscending(int lo, int hi) {
    assert lo < hi;
    int runHi = lo + 1;
    if (runHi == hi) {
      return 1;
    }
    // Find end of run, and reverse range if descending
    if (compare(runHi++, lo) == -1) { // Descending
      while (runHi < hi && compare(runHi, runHi - 1) == -1) {
        runHi++;
      }
      reverseRange(lo, runHi);
    } else { // Ascending
      while (runHi < hi && compare(runHi, runHi - 1) >= 0) {
        runHi++;
      }
    }

    return runHi - lo;
  }
the entrance of tim_sort; 1. array_size <= 32, use binary sort. 2. recursively invoke merge
sort.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/datastructure/TimSort.java