code: private static int[] computeMultilineReordering(byte[] levels, int[] linebreaks) {
          int[] result = new int[levels.length];
          
          int start = 0;
          for (int i = 0; i < linebreaks.length; ++i) {
              int limit = linebreaks[i];
              
              byte[] templevels = new byte[limit - start];
              System.arraycopy(levels, start, templevels, 0, templevels.length);
              
              int[] temporder = computeReordering(templevels);
              for (int j = 0; j < temporder.length; ++j) {
                  result[start + j] = temporder[j] + start;
              }
              
              start = limit;
          }
          
          return result;
      }
docs: Return multiline reordering array for a given level array.
  Reordering does not occur across a line break.