title: How to sort file or folder by filename or date at ascending or descending in Android?
body: <p>The following sample code is from Internet, I hope to sort <code>the List&lt;String&gt; files</code> by filename at ascending or descending.
  I hope to the L<code>ist&lt;String&gt; files</code> by date of file at ascending or descending, how can I do ? Thanks!</p>
  
  <p>The same quetsion with <code>List&lt;String&gt; directories</code>.</p>
  
  <pre><code>  List&lt;String&gt; files = Arrays.asList(f.list(new FilenameFilter() {
          @Override
          public boolean accept(File dir, String name) {
              File f=new File(dir, name);               
  
              return f.isFile()&amp;&amp;(f.isHidden()==false);
          }
      }));
      Collections.sort(files);
  
  
  
  
  List&lt;String&gt; directories = Arrays.asList(f.list(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
          File f=new File(dir, name);
          return f.isDirectory()&amp;&amp; (f.isHidden()==false);
      }
  }));
  Collections.sort(directories);
  </code></pre>