display order breaks when entering positions


There are some issues with the sorting of the chapters. I did a clean install of orchard with chapters being the only module installed. I entered the following chapter structure. No positions are entered.

  • c1.1





As it is above, it shows fine.

But if I take C2 and add a "position", say 7, trying to move it after c3, the display order breaks. It results in:



+c2.1 **



+c3.1 **

The problem appears to be related to the root nodes (c1,c2,c3) only. Child nodes sort properly when using the position. Children of children are sorted properly as well.

The following two functions are related to the display ordering:
    public IEnumerable<ChapterPart> GetChapters(BookPart book) {
       return  _contentManager.Query<ChapterPart, ChapterPartRecord>()
            .Where(part => part.Book == book.ContentItem.Record)
            .OrderBy(chapter => chapter);
public int CompareTo(ChapterPart other) {
return other.Container.As<IRoutableAspect>().Path == this.Container.As<IRoutableAspect>().Path
                ? Position.CompareTo(other.Position)
                : Path.CompareTo(other.Path);

I'm trying to find a fix, but it is related to the logic in CompareTo and whatever algorithm List.OrderBy() is using.. which is hard to trace. If I find something I'll follow up.


AdrianNoble wrote Sep 7, 2011 at 5:56 PM

Was there anything learned regarding this? My account team is all up in my business about this and if someone else is already aware of a fix that would be just wonderful!