feat: 🎸 optimize the computation of metrics
fixes #1604.

It seems like I had to first sort by the fields.
feat: 🎸 optimize the computation of metrics: fixes #1604.

It seems like I had to first sort by the fields.