Copied to clipboard

Flag this post as spam?

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


  • Lee 1123 posts 3059 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 3044 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 1123 posts 3059 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 1123 posts 3059 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 3044 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 1123 posts 3059 karma points
    Jun 03, 2010 @ 20:55
    Lee
    0

    Genius :)  Thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies