title: How to read list of files from directory, sorted on date modified, in Node JS
body: <p>Need to read list of files from particular directory with Date modified by descending or ascending in <strong>Node js</strong>.</p>
  
  <p>I have tried below code but could not get the solution.</p>
  
  <pre><code>fs.readdir(path, function (err, files) {
                      if (err) throw err;
                      else {
                          var res = [];
                          files.forEach(function (file) {
                              if (file.split('.')[1] == "json") {
                                  fs.stat(path, function (err, stats) {                                                                  
  
                                  });
                                  res.push(file.substring(0, file.length - 5));
                              }
                          });
                      }  
  </code></pre>
  
  <p>stats parameter give mtime as modified time?</p>
  
  <p>Is there any way to get files with modified date.</p>