title: Comparator<Object> Parcelable
body: <p>After hours of searching, I don't know how to make a Comparator parcelable. 
  I found this "Parcelable stuff" a bit "missing content"... (Parcelable don't have even a writeBoolean)</p>
  
  <pre><code>public class T implements Parcelable{
  
     ...
  
     public static Comparator&lt;T&gt; Compare = new Comparator&lt;T&gt;() {...}
  
     ...
  
     public void writeToParcel(Parcel out, int flags) {
          //how to write "Compare"
     }
  
     private T(Parcel in) {
          //how to read "Compare"
     }
  
  }
  </code></pre>
  
  <p>Thank you.</p>
  
  <p>EDIT:</p>
  
  <p>So here is the detail (simplified and adapted) about why the class F must be parcelable. Note that the code comes from a finished iOS project. It will be good for maintenance if the architecture stay the same... :-)</p>
  
  <pre><code>public class F implements Parcelable{
      …
      public ArrayList&lt;T&gt; listArray;
      public HashMap&lt;String,Comparator&lt;T&gt;&gt; sortElementMap;
  }
  </code></pre>
  
  <p>_</p>
  
  <pre><code>public class T implements Parcelable{
      …
      public static Comparator&lt;T&gt; CompareByName = new Comparator&lt;T&gt;() {…}};
      public static Comparator&lt;T&gt; CompareByDate = new Comparator&lt;T&gt;() { … }};
  }
  </code></pre>
  
  <p>First, in a configuration class (simplified here) allowing to adapt easily the application (column database matching between variables of T, filter/sort/search definition, ...)</p>
  
  <pre><code>F f=new F();
  f.sortElementMap.put("name",T.CompareByName)
  f.sortElementMap.put("date",T.CompareByDate)
  </code></pre>
  
  <p>In the previous activity</p>
  
  <pre><code>Intent intent=new Intent(…);
  intent.putExtra("F",F);
  startActivity(intent);
  </code></pre>
  
  <p>In the current activity</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
  …
      Intent intent = getIntent();
      f = (F)intent.getParcelableExtra("F");
  }
  
  
  // the list to be sorted
  listArray=new ArrayList&lt;String&gt;(f.listArray);
  
  listAdapter = new ListAdapter(this, R.layout.list_item, listArray);
      listView = (ListView) findViewById(R.id.listView);
      listView.setAdapter(listAdapter);
      listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          //@Override
          public void onItemClick(AdapterView arg0, View view,
                                  int position, long id) {
          …
          }
      });
  
  
  // the list with the different type of sorting
  
  sortArray=new ArrayList&lt;String&gt;();
  Iterator it = f.sortElementMap.entrySet().iterator();
      while (it.hasNext()) {
          Map.Entry pairs = (Map.Entry)it.next();
          sortArray.add((String) pairs.getKey());
      }
  
  sortListAdapter = new ListAdapter(this, R.layout.list_item_sort, sortArray);
      sortListView = (ListView) findViewById(R.id.sortListView);
      sortListView.setAdapter(sortListAdapter);
      sortListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          //@Override
          public void onItemClick(AdapterView arg0, View view,
                                  int position, long id) {
  
              applyCurrentSelectedSort();
  
          }
      });
  
  
  void applyCurrentSelectedSort(){
  
      Iterator it = f.sortElementMap.entrySet().iterator();
      while (it.hasNext()) {
          Map.Entry pairs = (Map.Entry) it.next();
  
          for (int i = 0; i &lt; sortListAdapter.getSelectedPosition().length; i++) {
              if (sortListAdapter.getSelectedPosition()[i]) {
                  listAdapter.sort((java.util.Comparator&lt;T&gt;) pairs.getValue());
                  break;
              }
          }
      }
  }
  </code></pre>