title: Fisher Yates Shuffle on a Cards List
body: <p>I'm trying to do the Fisher Yates shuffle on a list of Cards.  I've scoured forums and the only implementation of Fisher Yates is with normal int arrays like below</p>
  
  <pre><code>for (int i = length - 1; i &gt; 0; i--)
  {
    int j = random.Next(i + 1);
    int temp = array[i];
    array[i] = array[j];
    array[j] = temp;
  }
  </code></pre>
  
  <p>Which makes sense just fine, my trouble is I don't really see how to convert that logic to the way I have things, any help in accomplishing this would be greatly appreciated.  Relevant code below:</p>
  
  <pre><code>public struct Card : IComparable&lt;Card&gt;
  {
    public Rank Rank { get; private set; }
    public Suit Suit { get; private set; }
  
    public Card(Rank rank, Suit suit) : this()
    {
      Rank = rank;
      Suit = suit;
    }
  
    public override string ToString()
    {
      return string.Format("{0:x} {1}", (char) Suit, Rank);
    }
  }
  public enum Suit { Spades = 9824, Clubs = 9827, Hearts = 9829, Diamonds = 9830 }
  public enum Rank { Ace, Deuce, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King }
  
  public class Deck
  {
    public List&lt;Card&gt; Cards { get; private set; }
  
    public Deck()
    {
      foreach (Rank rank in Enum.GetValues(typeof(Rank)))
      {
        foreach (Suit suit in Enum.GetValues(typeof(Suit)))
        {
          Card card = new Card(rank, suit);
          Cards.Add(card);
        }
      }
    }
    public Deck(List&lt;Card&gt; cardDeck)
    {
      Cards = cardDeck;
    }
    public void Shuffle()
    {  //???? I don't know how I would apply the Fisher Yates logic to here
       //since all other programs just use normal int arrays
    . . .
  </code></pre>
  
  <p>Thanks for any and all help.</p>