by jjgreen·8y ago·view on hn ↗That costs a sort, better to use the Kahan summation formula https://en.wikipedia.org/wiki/Kahan_summation_algorithm