Skip to content

Commit 261a4b3

Browse files
committed
🐞 fix: Improve condition check in sortTranslatedCountries for better handling of missing values
1 parent 88550a3 commit 261a4b3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/utils/nationTranslationHelper.svelte.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ export const sortTranslatedCountries = (
319319
a: { alpha3Code?: string | null; name?: string | null; [key: string]: any },
320320
b: { alpha3Code?: string | null; name?: string | null; [key: string]: any }
321321
) => {
322-
if (!a.alpha3Code || !a.name || !b.alpha3Code || !b.name) return 0;
322+
if ((!a.alpha3Code && !a.name) || (!b.alpha3Code && !b.name)) return 0;
323323
return (a.name ?? getTranslatedCountryNameFromAlpha3Code(a.alpha3Code)).localeCompare(
324324
b.name ?? getTranslatedCountryNameFromAlpha3Code(b.alpha3Code)
325325
);

0 commit comments

Comments
 (0)