This is Lukas M's Typepad Profile.
Join Typepad and start following Lukas M's activity
Join Now!
Already a member? Sign In
Lukas M
Recent Activity
I hope this comment will bubble up. Post has a lot of good details, but there is a problem with the second code in C#. var cards = Enumerable.Range(0, 51); var shuffledcards = cards.OrderBy(a => Guid.NewGuid()); There are two problems with it covered by Eric Lippert: Do not use a random function as a comparator and feed that to a sorting algorithm. Sort algorithms are permitted to do anything they please if the comparator is bad, including crashing, and including producing non-random results. As Microsoft recently found out, it is extremely embarrassing to get a simple algorithm like this wrong. Do not sort on a "random" GUID as your key. GUIDs are guaranteed to be unique. They are not guaranteed to be randomly ordered. It is perfectly legal for an implementation to spit out consecutive GUIDs. Source: http://stackoverflow.com/questions/5519385/calling-a-list-of-methods-in-a-random-sequence/5519621#5519621 Kind Regards, Lukas M
Toggle Commented Apr 13, 2011 on Shuffling at Coding Horror
Lukas M is now following The Typepad Team
Apr 13, 2011