title: How can I sort files in a directory in java?
body: <p>Here is my code and it works ! But I want to be able to sort the files list according to name, size, modification date and more</p>
  
  <pre><code>import java.io.File;
  import org.apache.commons.io.FileUtils;
  
  public class StartingPoint {
      public static void main(String[] args) {
          File file = new File(
                  "/home/t/lectures");
          File[] files = file.listFiles();
          for (File f : files) {
              System.out.println("File : " + f.getName() + " ["
                      + FileUtils.byteCountToDisplaySize(f.length()) + "]");
          }
      }
  }
  </code></pre>