diff --git a/src/app/foldernav.ts b/src/app/foldernav.ts index ff7d908..c98409c 100644 --- a/src/app/foldernav.ts +++ b/src/app/foldernav.ts @@ -86,7 +86,7 @@ export const FolderTreeView = () => { u.InlineButton(refreshFolder, "Refresh current folder", "⟳"), u.InlineButton(openFolder, "Open another folder", "📁"), ), - folderTreeState.val.children?.map(FsItemView) || [], + folderTreeState.val.children?.toSorted((a, b) => a.type.localeCompare(b.type)).map(FsItemView) || [], ); }; @@ -104,9 +104,11 @@ const FsItemView = (tree: FolderTree): HTMLElement => { tree.name, ); const isOpen = van.state(false); + const sorted = tree.children?.toSorted((a, b) => + a.type.localeCompare(b.type)); const children = () => isOpen.val - ? v.ul({ class: "pl-4" }, tree.children?.map(FsItemView)) + ? v.ul({ class: "pl-4" }, sorted.map(FsItemView)) : v.div({ ariaBusy: true }); const folder = v.details( {