You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
spa_instat_tv/src/helpers/getSortedLangs/index.tsx

11 lines
489 B

import sortBy from 'lodash/sortBy'
import { ReferenceLanguages } from 'requests/getLanguages'
export const getSortedLangs = (langs: ReferenceLanguages): ReferenceLanguages => {
const languagesSorted = sortBy(langs, ['name_en'])
const engLocaleIndex = languagesSorted.findIndex((language) => language.iso_639_1 === 'en')
const engLanguage = languagesSorted[engLocaleIndex]
languagesSorted.splice(engLocaleIndex, 1)
languagesSorted.unshift(engLanguage)
return languagesSorted
}