Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Lee 1130 posts 3088 karma points
    Jun 02, 2010 @ 22:25
    Lee
    0

    Sorting Nodes With NodeFactory?

    Is it possible to sort nodes by createDate using NodeFactory?

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jun 03, 2010 @ 00:57
    Aaron Powell
    0

    Yes, most nodeFactory methods return arrays which you can sort with standard array sorting methods or you can use LINQ.

  • Lee 1130 posts 3088 karma points
    Jun 03, 2010 @ 07:45
    Lee
    0

    Sorry bud I think I am being a bit dumb here, but I can't get it work?

                    // Get the parent node
                    Node myNode = new Node(1121);
    
                    // Now get all the children
                    Nodes SubPages = myNode.Children;

    I tried .Sort() on SubPages but that isn't an option?  To use LINQ do you mean install that LINQ add on class you created?

  • Lee 1130 posts 3088 karma points
    Jun 03, 2010 @ 15:38
    Lee
    0

    Just in case anyone else has this problem, my solution was to loop through the nodes and add the to a List<T> and then use a lambda expression

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jun 03, 2010 @ 15:47
    Aaron Powell
    1

    You can just do:

    var subPages = myNode.Children.Cast<Node>().OrderBy(x => x.CreateDate);

     

  • Lee 1130 posts 3088 karma points
    Jun 03, 2010 @ 20:55
    Lee
    0

    Genius :)  Thanks

Please Sign in or register to post replies

Write your reply to:

Draft