Use of comparator in user defined class