Wrote compareTo() method