title: Sorting an array in java with certain conditions
body: <p>I have a class called Athlete which is a sublass of Human. In the class Human I implement the interface comparable and use the method compareTo in order to compare the ages of different athletes. In the athletes class I have an extra field called year which corresponds to the year the athlete started competing. In my main method in my program I have an arraylist that I add both Athletes and Humans. I would like to so that if an athlete is of the same age to sort according to the year the athlete started competing. I use instanceof to check in my class human if the instance is the object is of type Athlete but after that I don't know how to get it to work.</p>
  
  <pre><code>    public int compareTo(Human other)
      {
  
          if(this instanceof Athlete &amp;&amp; other instanceof Athlete &amp;&amp; this.age == other.age){
              return ;
          }
          return this.age - other.age;
      }
  }
  </code></pre>