I have written the following code to sort the left hand side of multilist using code:
public Item[] ListQuery(Item item)
{
try {
List<Item> sourceItems = new List<Item>();
item = Sitecore.Context.ContentDatabase.GetItem("/sitecore/content/website/Home/newsroom");
List<Item> otherCampaigns = item
.GetChildren()
.Where(x => x.TemplateID.ToString().Equals("{D5016838-1EC3-476A-9270-F9995C57AD5B}"))
.OrderByDescending(x => x[Sitecore.FieldIDs.Updated])
.ToList();
sourceItems.AddRange(otherCampaigns);
return sourceItems.ToArray();
}
catch
{
return new Item[0];
}
}
I am getting the correct order of sorted items in the code but in the left hand side of multilist field it is not populating in the same order as in "sourceItems" in the code.In multilist field the items are coming in any random order.Kindly assist