Shuffling cards
I have a Vector with 52 objects of type "Card" (which consist of an int (value) and a String (color)).I need some kind of method to "shuffle" the cards, or randomize the order of them.
As of now, I use:
Collections.sort(_cards, _shuffler);
where _shuffler is a Comparator looking like this:
public int compare(Object o1, Object o2)
{
return (int)((Math.random() - 0.5) * 100);
}
Can you see any drawbacks with my shuffling method? Can you think of a better one. More accurate, or perhaps faster?
Answer in danish, swedish or english :)