Browse Source

Sort stash by modified time

Alex Myasoedov 6 years ago
parent
commit
45d74b4d9b
1 changed files with 6 additions and 0 deletions
  1. 6 0
      main.go

+ 6 - 0
main.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"os"
+	"sort"
 	"strings"
 
 	log "github.com/Sirupsen/logrus"
@@ -125,6 +126,11 @@ func NewApp() *gin.Engine {
 		if err != nil {
 			log.Fatal(err)
 		}
+
+		sort.Slice(files, func(i, j int) bool {
+			return files[i].ModTime().Unix() > files[j].ModTime().Unix()
+		})
+
 		var stash []string
 		for _, file := range files {
 			if file.IsDir() {