diff --git a/files.go b/files.go index 46d5493..d027dad 100644 --- a/files.go +++ b/files.go @@ -6,10 +6,12 @@ import ( "net/http" "os" "path/filepath" + "slices" + "strings" "time" ) -const fileElement = "

%v

%v

" +const fileElement = "
%v
%v
" func filesRequest(w http.ResponseWriter, r *http.Request) { partPath := filepath.Clean(r.URL.Path) @@ -30,6 +32,9 @@ func filesRequest(w http.ResponseWriter, r *http.Request) { if stat.IsDir() { var dirs []os.DirEntry dirs, err = fil.ReadDir(-1) + slices.SortFunc(dirs, func(a, b os.DirEntry) int { + return strings.Compare(a.Name(), b.Name()) + }) if err != nil { pageContent = "

Server error!

" w.WriteHeader(http.StatusInternalServerError)