AI OnAI Off
using System.Collections;
.
.
.
.
public class LanguageSelector : EPiServer.UserControlBase
{
private class LangSort : IComparer
{
int IComparer.Compare(object x, object y)
{
PageData pageX = x as PageData;
PageData pageY = y as PageData;
if (pageX != null || pageY != null)
{
LanguageBranch langX = LanguageBranch.Load(pageX.LanguageBranch);
LanguageBranch langY = LanguageBranch.Load(pageY.LanguageBranch);
return langX.SortIndex.CompareTo(langY.SortIndex);
}
else
return 0; //**** Handle as you see fit
}
}
protected PageList languageList;
private void Page_Load(object sender, System.EventArgs e)
{
if(Configuration.EnableGlobalizationSupport && CurrentPage.PageLink.IsValue())
{
PageDataCollection pages = Global.EPDataFactory.GetLanguageBranches(CurrentPage.PageLink);
pages.Sort(new LangSort() );
languageList.DataSource = pages;
languageList.DataBind();
}
else
Visible = false;
}