x First time here? Check out the FAQ
Join us a the Umbraco event of the year - get your Codegarden 14 early bird ticket today
  • Avatar348posts684karma

    DynamicNodeList shuffling

    Moshe Kariti started this topic March 4, 2012 @ 01:48, Go directly to the topic solution

    Hi there,

    Is there an quick way to shuffle DynamicNodeList?

    Cheers

    mkariti


  • Moshe Kariti posted this reply March 4, 2012 @ 02:43

    Got it! I used this:

     

    Random r = new Random(); 
         for (int n = pagesToList.Count() - 1; n > 0; --n)
         {
             int k = r.Next(n + 1);
             DynamicNode temp = pagesToList.Items[n];
             pagesToList.Items[n] = pagesToList.Items[k];
             pagesToList.Items[k] = temp;
         }
      

Please login or Sign up To post replies