Hacker News new | ask | show | jobs
by re 3840 days ago
It can be extremely biased, and the results can depend on the sort algorithm, because what you're randomizing is the comparison results, not the order. Consider insertion sort: https://en.wikipedia.org/wiki/Insertion_sort

As the list is sorted, elements are inserted from the back by finding the first element that the new element is smaller than. The last element to be inserted is the one at the end of the unsorted array, and, with a random comparator, it has a 50% chance of being "larger" than the biggest of the rest of the elements, and thus remaining at the end of the list.

Microsoft used this technique to "randomize" a list of browsers back in 2010, but, when viewing the page in IE, it ended up putting IE in the last position (out of a set of five browsers) 50% of the time: http://www.robweir.com/blog/2010/02/microsoft-random-browser...

1 comments

Ah, yes; that's a great point about the sort algorithm!