title: sorting in recycler view by size,date,name .etc and remember choice
body: <p>I am making gallery app and I want to add sorting to it I can sort item at run time by using <code>Comparator</code>but problem is whenever I quit app the list came form database again and all the list is unsorted I want to give option in my app to sort by date,size, name etc can you guys help how can i ahcevie this and remmeber user's choice if he next time run the app I have also read about sorted-list please tell me what is solution to my problem or any sample code currently I am doing this like this to sort items </p>
  
  <pre><code>public static final Comparator&lt;MediaFileObject&gt; byName=new Comparator&lt;MediaFileObject&gt;() {
      @Override
      public int compare(MediaFileObject o1, MediaFileObject o2) {
  
          return o1.getAddedDate().compareTo(o2.getAddedDate());
      }
  };
  </code></pre>
  
  <p>and i call this in my fragment</p>
  
  <pre><code>Collections.sort(list,MediaFileObject.byName);
  galleryAdapter.notifyDataSetChanged()
  </code></pre>
  
  <p>this is working fine but i want to remember user sorting choice please someone help what should i do?
  can i achieve this by using <code>SortedList</code>? or any sample code please</p>