github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/os/default/sort.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package dos 4 5 import ( 6 goos "os" 7 "sort" 8 ) 9 10 // ByModTime use to 11 type ByModTime []goos.FileInfo 12 13 func (fis ByModTime) Len() int { 14 return len(fis) 15 } 16 17 func (fis ByModTime) Swap(i, j int) { 18 fis[i], fis[j] = fis[j], fis[i] 19 } 20 21 func (fis ByModTime) Less(i, j int) bool { 22 return fis[i].ModTime().Before(fis[j].ModTime()) 23 } 24 25 // SortFilesDec sort given slice in dec 26 func SortFilesDec(repoFiles []goos.FileInfo) { 27 sort.Sort(ByModTime(repoFiles)) 28 }