Use a re-usable Intl.Collator instance for locale compare when possible (#1638)

* Use a re-usable Intl.Collator instance for locale compare
This commit is contained in:
Damien Erambert
2026-02-02 18:28:01 -08:00
committed by GitHub
parent a45b607fe7
commit 72fc5beb98
3 changed files with 28 additions and 16 deletions
@@ -88,6 +88,8 @@ import {
} from '/@/shared/types/domain-types';
import { ItemListKey, ListDisplayType, Play } from '/@/shared/types/types';
const collator = new Intl.Collator();
interface AlbumArtistActionButtonsProps {
artistDiscographyLink: string;
artistSongsLink: string;
@@ -1251,12 +1253,12 @@ const ArtistAlbums = ({ albumsQuery }: ArtistAlbumsProps) => {
const secondaryKeyB = getSecondaryTypePriorityKey(b.releaseType);
if (secondaryKeyA && secondaryKeyB) {
return secondaryKeyA.localeCompare(secondaryKeyB);
return collator.compare(secondaryKeyA, secondaryKeyB);
}
}
// Fallback to alphabetical for non-combined types or if weighted comparison isn't applicable
return a.releaseType.localeCompare(b.releaseType);
return collator.compare(a.releaseType, b.releaseType);
});
}, [albumsByReleaseType, artistReleaseTypeItems, t]);