docs: private static double weightedAverageSorted(double x1, double w1, double x2, double w2) {
          assert x1 <= x2;
          final double x = (x1 * w1 + x2 * w2) / (w1 + w2);
          return Math.max(x1, Math.min(x, x2));
      }