Since Sitecore 8.1 Update 2, one has been able to set the display order of languages in the Content Editor to follow the order of language items under /sitecore/system/Languages using the setting ContentEditor.SortLanguages. However, this has no impact on the order of languages from Database.GetLanguages(). Is there a way to apply this functionality to a front-end component, so that for example a language selector widget follows the language order of /sitecore/system/languages?
1 Answer
You can use LanguageComparer to apply this ordering:
var sortedLangauges = currentItem.Database.GetLanguages.OrderBy((x => x),new LanguageComparer(currentItem.Database));
This is what the ContextEditor.SortLangauges setting uses behind the scenes.