title: How to get the latest file from a directory using groovy?
body: <p>I have a directory that contains a list of files. I wanted to get the latest file out of all the contents of the said directory. How will I do that?</p>
  
  <p>I am using this code, but I am not getting the latest file out of it. Please help.</p>
  
  <pre><code>def fileDir = new File("A/B").listFiles().first()
  </code></pre>
  
  <p>Thanks.</p>