operator < method

bool operator <(
  1. Complex other
)

There is no natural linear ordering for complex numbers. In fact, any square in an ordered field is >= 0 but in the complex field we have that i2 = -1.

A possible comparison strategy involves comparing the modulus/magnitude abs of the two complex number.

In this implementation, we compare two Complex instances by looking at their modulus/magnitude.

Implementation

bool operator <(Complex other) => abs() < other.abs();