use lodash to sort

This commit is contained in:
piradata 2024-05-30 02:48:23 -03:00
parent 5e019c41f4
commit d62039fba1

View File

@ -9,6 +9,7 @@ import { useAppSelector } from "@renderer/hooks";
import { changeLanguage } from "i18next"; import { changeLanguage } from "i18next";
import * as languageResources from "@locales"; import * as languageResources from "@locales";
import { orderBy } from "lodash-es";
interface LanguageOption { interface LanguageOption {
option: string; option: string;
@ -47,18 +48,16 @@ export function SettingsGeneral({
fetchdefaultDownloadsPath(); fetchdefaultDownloadsPath();
setLanguageOptions( setLanguageOptions(
Object.keys(languageResources) orderBy(
.map((language) => { Object.keys(languageResources).map((language) => {
return { return {
nativeName: ISO6391.getNativeName(language), nativeName: ISO6391.getNativeName(language),
option: language, option: language,
}; };
}) }),
.sort((a, b) => { ["nativeName"],
if (a.nativeName < b.nativeName) return -1; "asc"
if (a.nativeName > b.nativeName) return 1; )
return 0;
})
); );
}, []); }, []);