title: Sorting ArrayList - JAVA
body: <p>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 &quot;Person&quot; 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.</p>
  <pre><code>Comparator&lt;Person&gt; comparator = new Comparator&lt;Person&gt;() {
              
  @Override
          
  public int compare(Person first, Person second) {
                  if (first.age &lt; second.age) {
                      return first.age;
                  } else {
                      return second.age;
                  }
              }
          };
          Collections.sort(myList, comparator);
      enter code here
  </code></pre>
  <p>Kind Regards.</p>