1
0
Fork 0
mirror of https://git.sr.ht/~ashkeel/strimertul synced 2024-09-18 01:50:50 +00:00
strimertul/utils/file.go

20 lines
318 B
Go
Raw Normal View History

package utils
2022-02-08 14:13:45 +00:00
import "os"
type ByDate []os.DirEntry
func (f ByDate) Len() int {
return len(f)
}
func (f ByDate) Swap(i, j int) {
f[i], f[j] = f[j], f[i]
}
func (f ByDate) Less(i, j int) bool {
firstInfo, _ := f[i].Info()
secondInfo, _ := f[i].Info()
return firstInfo.ModTime().Before(secondInfo.ModTime())
}