Kentico 9 - Sorting pages in the content tree
// Creates an instance of the Tree provider
TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
// Gets the parent page
TreeNode page = tree.SelectNodes()
.Path("/Articles")
.OnCurrentSite()
.Culture("en-us")
.FirstObject;
if (page != null)
{
bool orderIsAscending = true;
// Sorts all child pages under the specified parent page alphabetically in ascending order
tree.SortNodesAlphabetically(page.NodeID, SiteContext.CurrentSiteID, orderIsAscending);
// Sorts all child pages under the specified parent page ascendingly based on the last modification date
tree.SortNodesByDate(page.NodeID, SiteContext.CurrentSiteID, orderIsAscending);
}