add by directory status sorting

This commit is contained in:
Lilian Jónsdóttir 2024-07-15 15:08:02 -07:00
parent dc0aab172d
commit de81cfbfed

View file

@ -13,11 +13,13 @@ const (
PathReverse PathReverse
Size Size
SizeReverse SizeReverse
Directory
DirectoryReverse
) )
func (s Sorting) Next() Sorting { func (s Sorting) Next() Sorting {
switch s { switch s {
case SizeReverse: case DirectoryReverse:
return Name return Name
default: default:
return s + 1 return s + 1
@ -27,7 +29,7 @@ func (s Sorting) Next() Sorting {
func (s Sorting) Prev() Sorting { func (s Sorting) Prev() Sorting {
switch s { switch s {
case Name: case Name:
return SizeReverse return DirectoryReverse
default: default:
return s - 1 return s - 1
} }
@ -51,6 +53,10 @@ func (s Sorting) String() string {
return "size" return "size"
case SizeReverse: case SizeReverse:
return "size (r)" return "size (r)"
case Directory:
return "directories first"
case DirectoryReverse:
return "directories last"
default: default:
return "0" return "0"
} }
@ -74,6 +80,10 @@ func (s Sorting) Sorter() func(a, b files.File) int {
return files.SortBySize return files.SortBySize
case SizeReverse: case SizeReverse:
return files.SortBySizeReverse return files.SortBySizeReverse
case Directory:
return files.SortDirectoriesFirst
case DirectoryReverse:
return files.SortDirectoriesLast
default: default:
return files.SortByName return files.SortByName
} }