Numeric sorting and filter. "New Folder 12" > "New Folder 2"
This commit is contained in:
@@ -180,7 +180,7 @@ const toggleSort = (name: string) => {
|
||||
}
|
||||
const sort = ref<string>('')
|
||||
const sortCompare = {
|
||||
name: (a: Document, b: Document) => a.name.localeCompare(b.name),
|
||||
name: (a: Document, b: Document) => a.name.localeCompare(b.name, undefined, {numeric: true, sensitivity: 'base'}),
|
||||
modified: (a: FolderDocument, b: FolderDocument) => b.mtime - a.mtime,
|
||||
size: (a: FolderDocument, b: FolderDocument) => b.size - a.size
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ export const useDocumentStore = defineStore({
|
||||
}
|
||||
// Pre sort directory entries folders first then files, names in natural ordering
|
||||
dataMapped.sort((a, b) =>
|
||||
a.type === b.type ? a.name.localeCompare(b.name) : a.type === 'folder' ? -1 : 1
|
||||
a.type === b.type ? a.name.localeCompare(b.name, undefined, {numeric: true, sensitivity: 'base'}) : a.type === 'folder' ? -1 : 1
|
||||
)
|
||||
this.document = dataMapped
|
||||
},
|
||||
@@ -85,6 +85,7 @@ export const useDocumentStore = defineStore({
|
||||
if (
|
||||
localeIncludes(name, filter, {
|
||||
usage: 'search',
|
||||
numeric: true,
|
||||
sensitivity: 'base'
|
||||
})
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user