code: function areaUnder(curve, sortx) {
    const sorted = sortx ? curve.sort((a, b) => a.x - b.x) : curve;
    let auc = 0;
    let {x, y} = sorted[0];
  
    for (let i = 0; i < sorted.length; i++) {
      let e = sorted[i];
      auc += (e.x - x) * (y + (e.y - y) / 2);
      x = e.x;
      y = e.y;
    }
    return auc;
  }
docs: Compute area under curve, where curve is an Array of Objects {x, y}