title: Sorting a Recyclerview list dynamically
body: <p>I have a recyclerview list that is a check list. I want it to be sorted based on date and if the checkbox is checked or not. So if the user is on the main screen he/she should see a sorted list based on date and if he/she clicks a checkbox, I want that item to go the bottom of the list.</p>
  
  <p>I wrote a compareTo method in the model class:</p>
  
  <pre><code>public int compareTo(BucketItem o) {
      if (this.isChecked &amp;&amp; !o.isChecked){
          return -1;
      }else if(!this.isChecked &amp;&amp; o.isChecked){
          return 1;
      }else if (this.isChecked &amp;&amp; o.isChecked){
          return 0;
      }else{
          return getDate().compareTo(o.getDate());
      }
  }
  </code></pre>
  
  <p>The layout looks for one item looks like this:</p>
  
  <pre><code>&lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="horizontal"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:paddingTop="13dp"
      android:paddingBottom="13dp"
      android:weightSum="1"&gt;
  
      &lt;!--&lt;TextView--&gt;
          &lt;!--android:id="@+id/contact_name"--&gt;
          &lt;!--android:layout_width="0dp"--&gt;
          &lt;!--android:layout_height="wrap_content"--&gt;
          &lt;!--android:layout_weight="1"--&gt;
          &lt;!--/&gt;--&gt;
      &lt;RelativeLayout
          android:layout_height="52dp"
          android:layout_width="wrap_content"
          android:id="@+id/RelativeLayout1"
          android:orientation="vertical"
          android:layout_marginBottom="16dp"
          android:layout_weight="0.95"&gt;
          &lt;CheckBox
              android:id="@+id/checkBox1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:layout_centerVertical="true"
              android:clickable="true"
              android:onClick="itemClicked"
               /&gt;
  
          &lt;TextView
              android:id="@+id/bucket_name"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_toRightOf="@id/checkBox1"
              android:layout_centerVertical="true"
              android:text="TextView"
              android:clickable="true"
              android:onClick="editItem"/&gt;
  
          &lt;TextView
              android:text="TextView"
              android:id="@+id/bucket_des"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_weight="1"
              android:layout_below="@+id/bucket_name"
              android:layout_toEndOf="@+id/checkBox1" /&gt;
  
  
      &lt;/RelativeLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>My main question is where do I put the Collections.sort(list) so that it gets called every time a new item gets added to the list or a checkbox gets checked? </p>