Skip to content

Commit

Permalink
fix: tabs sorting by url: natural numerical sorting (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbnuqw committed Mar 4, 2024
1 parent 0ef59a8 commit c1c4bb3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/services/tabs.fg.sorting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export async function sort(type: By, ids: ID[], dir = 0, tree?: boolean) {

// or Sort by URL
else if (type === By.Url) {
const collatorOptions = { numeric: true }
const sortableUrls = new Map<ID, string>()
await sortTabsInChunks(sortingChunks, (aId, bId) => {
const aTab = Tabs.byId[aId]
Expand All @@ -96,8 +97,8 @@ export async function sort(type: By, ids: ID[], dir = 0, tree?: boolean) {
}
const aLink = getSortableLink(sortableUrls, aTab)
const bLink = getSortableLink(sortableUrls, bTab)
if (dir > 0) return aLink.localeCompare(bLink)
else return bLink.localeCompare(aLink)
if (dir > 0) return aLink.localeCompare(bLink, undefined, collatorOptions)
else return bLink.localeCompare(aLink, undefined, collatorOptions)
}).catch(() => {})
}

Expand Down

0 comments on commit c1c4bb3

Please sign in to comment.