I have a csv file which includes 3 columns (name,gender,age) and it's irregular(not sorted). I have created a class which name is "Person" and add to a Araylist each column of the csv file by the Person object. Afterthat I wanted to sort this list however it's not sorting. The list occurs as the same the csv file. My code which I expected to sort is below. Could you please check why this code not sorting my list according to age.
Comparator<Person> comparator = new Comparator<Person>() {
            
@Override
        
public int compare(Person first, Person second) {
                if (first.age < second.age) {
                    return first.age;
                } else {
                    return second.age;
                }
            }
        };
        Collections.sort(myList, comparator);
    enter code here
Kind Regards.
 
     
    