github.com/aarzilli/tools@v0.0.0-20151123112009-0d27094f75e0/os/fsi/osfs/sort.go (about)

     1  package osfs
     2  
     3  import "os"
     4  
     5  type byDateAsc []os.FileInfo
     6  
     7  func (f byDateAsc) Len() int           { return len(f) }
     8  func (f byDateAsc) Less(i, j int) bool { return f[i].ModTime().Before(f[j].ModTime()) }
     9  func (f byDateAsc) Swap(i, j int)      { f[i], f[j] = f[j], f[i] }
    10  
    11  type byDateDesc []os.FileInfo
    12  
    13  func (f byDateDesc) Len() int           { return len(f) }
    14  func (f byDateDesc) Less(i, j int) bool { return f[i].ModTime().After(f[j].ModTime()) }
    15  func (f byDateDesc) Swap(i, j int)      { f[i], f[j] = f[j], f[i] }