In Sitecore, I thought that sortorder always took precedence over subitem sorting. I was under the assumption that it doesn't matter what an item's subitem sorting was set to if one of it's children had a sortorder of 100 and the other had one of 0 the one with 0 would show up first. On a recent project I'm seeing the opposite happen in the content tree. Subitem sorting is being given the priority. Is there a way to configure the order in which sortorder and subitem sorting is checked? I've been looking around my web.config and diffed it with one I had for a project that was working the way I thought it should but I couldn't find anything that jumped out to me.
Visual of what I'm seeing in the content tree for the project that seems to give subitem sorting priority:
parent - subitem sorting = created
child1 - created = 01012014, sortorder = 100
child2 - created = 02022014, sortorder = 0
This may be a bug in Sitecore but it also may be working as intended, you may have to contact Sitecore support to find out which.
The Child Sorting for "Created" points to Sitecore.Data.Comparers.CreatedComparer,Sitecore.Kernel. If you look at the ExtractKey() method in this class you will see that it does not include the original item's SortOrder. Without out this Sitecore will only sort on Created Date.
public override IKey ExtractKey(Item item)
{
Assert.ArgumentNotNull(item, "item");
KeyObj keyObj = new KeyObj()
{
Item = item,
Key = this.GetCreationDate(item)
};
return keyObj;
}
In contrast you can look at the Child Sorting for "Updated" which points to Sitecore.Data.Comparers.UpdatedComparer,Sitecore.Kernel. In its ExtractKey() method you see it is returning the item's Sort order so you will get a blended sort between Updated Date and Sort Order.
public override IKey ExtractKey(Item item)
{
Assert.ArgumentNotNull(item, "item");
KeyObj keyObj = new KeyObj()
{
Item = item,
Key = item.Statistics.Updated,
Sortorder = item.Appearance.Sortorder
};
return keyObj;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With