Copied to clipboard

Flag this post as spam?

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


  • prl 32 posts 54 karma points
    Mar 24, 2010 @ 13:20
    prl
    0

    Sorting Nodes

    Hello,

    Is it possible to sort a List of Nodes by its CreateDate so that I have the Nodes listed from the most recent to the oldest (I'm using Visual Studio)?

    Thanks

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Mar 24, 2010 @ 13:28
    Rasmus Berntsen
    0

    In XSLT or?

    If yes, then something like this should do it (from the top of my head):

    <xsl:for-each select="$currentPage/node">

    <xsl:sort select="@createDate" order="descending" />

    <xsl:value-of select="@nodeName" />

    </xsl:for-each>

  • prl 32 posts 54 karma points
    Mar 24, 2010 @ 15:52
    prl
    0

    I think that would work, but I need to do this in code :)

  • Ken Mark 82 posts 94 karma points
    Mar 24, 2010 @ 17:59
    Ken Mark
    2

    If you wanna do it in code behind I think this is the way to do it. If there is a better way please let me know!

     

    Node parent = new Node(1070);
    Node[] nodes = new Node[parent.Children.Count];
    for (int i = 0; i < nodes.Length; i++)
        nodes[i] = parent.Children[i];

    Array.Sort(nodes, delegate(Node node1, Node node2) {
        return node1.SortOrder.CompareTo(node2.SortOrder);
    });

     

Please Sign in or register to post replies

Write your reply to:

Draft