title: How is the rule for sorting a list in ascending order and descending order?
body: <p>I have been trying to understand how sorting using Comparable works. I have class Activity implementing Comparable interface. I am trying to understand how activity.finish-this.finish; sorts in descending order and how this.finish-activity.finish sorts in ascending order. I am confused about what to use first for sorting in ascending and descending?</p>
  <pre><code>class Activity implements Comparable {
      int start;
      int finish;
  
      public Activity(int start, int finish) {
          this.start = start;
          this.finish = finish;
      }
  
      @Override
      public int compareTo(Object o) {
          Activity activity = (Activity) o;
          return  activity.finish-this.finish;
      }
  }
  
  public class ActivitySelectionProblem {
      public static void main(String[] args) {
          int start[]  =  {1, 3, 0, 5, 8, 5};
          int finish[] =  {2, 4, 10, 7, 9, 9};
  
          List&lt;Activity&gt; list = new ArrayList&lt;&gt;();
          for(int i = 0 ; i &lt; start.length ; i++){
              list.add(new Activity(start[i], finish[i]));
          }
  
          Collections.sort(list);
      }
  }
  </code></pre>