public ActionResult Index(string sortParam = "id") { var treeRoot = new TreeElement().CreateTreeFromFlatNodes(repository.TreeNodes.ToList()); switch (sortParam) { case "alp": treeRoot.SortTreeNodes(e => e.Content); break; case "id": treeRoot.SortTreeNodes(e => e.Id.ToString()); break; case "childam": treeRoot.SortTreeNodes(e => e.Children.Count.ToString()); break; } return(View(treeRoot)); }