I need to display a list of items based on their path. For instance:

Content tree setup: enter image description here

I am trying to sort results by item path, so if I perform a search that matches the items in the below list then the results would display in the following order, regardless of relevance, age, etc.:

  • CategoryA
  • Book1
  • Article1
  • CategoryB
  • Book2
  • Article4

I have tried using .OrderBy(x => [SearchReturnedItem].Paths.Path).ToArray(), but it's not working. Does anyone have any suggestions that might help?

edit - code moved to question body

using (var searchContext = ContentSearchManager.GetIndex("<indexname>").CreateSearchCon‌​text()) 
    var result = searchContext.GetQueryable<SearchResultItem>()
      .Where(x => x.TemplateId.Guid.ToString()

    var sortedResult = result.OrderBy(x => x.Path); 
  • 2
    Have you tried OrderBy(x => x.Path)?
    – Marek Musielak
    Commented Jan 26, 2017 at 9:46

1 Answer 1


The [SearchReturnedItem].Paths.Path) is going to to return the list of ItemIDs for the path. You'll want to instead sort by [SearchReturnedItem].Path which will sort by the full text path you are looking for.

  • 1
    Assuming [SearchReturnedItem] is a SearchResultItem then technically [SearchReturnedItem].Paths.Path should result in a compilation error since SearchResultItem.Paths is an IEnumerable<ID>, but you are correct that what the OP is looking for is SearchResultItem.Path :) +1 Commented Jan 26, 2017 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.