<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Comments on snippet: 'Unique Random Array'</title>
    <description>Snipplr comments feed</description>
    <link>https://ipv6.snipplr.com/</link>
    <lastBuildDate>Sun, 05 Apr 2026 17:59:42 +0000</lastBuildDate>
    <item>
      <title>cessnajumpin said on 27/Aug/2009</title>
      <link>https://ipv6.snipplr.com/view/13636/unique-random-array</link>
      <description>&lt;p&gt;Hahaha......wow. &#13;
&#13;
You may want to take another look there. Shuffle does nothing other than return a -1,0, or 1 to be used with the sort function (and that function is well documented by Adobe, probably because it's one of theirs).&#13;
Amazingly, arrays can contain strings! I know it's a simple concept, but can understand how that could be confusing.&#13;
&#13;
Anyways, there's nothing wrong with my code.&lt;/p&gt;</description>
      <pubDate>Thu, 27 Aug 2009 14:31:02 UTC</pubDate>
      <guid>https://ipv6.snipplr.com/view/13636/unique-random-array</guid>
    </item>
    <item>
      <title>GillesL said on 20/Feb/2011</title>
      <link>https://ipv6.snipplr.com/view/13636/unique-random-array</link>
      <description>&lt;p&gt;This function works but one should know that it doesn't produce an even randomization. In the exemple above, the array length is 6, so each item should have a probability of 1/6 to be found at any place in the randomized result. It's not the case. Here is a little test I built to convince myself :&#13;
&lt;code&gt;&#13;
	function shuffle($a:Array):Array&#13;
		{&#13;
			return $a.sort( function ($a,$b):int&#13;
			{&#13;
				var sortNum : int = Math.round(Math.random() * 2) - 1;&#13;
				return sortNum;&#13;
			});&#13;
		}&#13;
	&#13;
	var count:Array = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]];&#13;
	var tmp:Array;&#13;
	for (var i=0; i&lt;/p&gt;</description>
      <pubDate>Sun, 20 Feb 2011 22:01:51 UTC</pubDate>
      <guid>https://ipv6.snipplr.com/view/13636/unique-random-array</guid>
    </item>
    <item>
      <title>GillesL said on 20/Feb/2011</title>
      <link>https://ipv6.snipplr.com/view/13636/unique-random-array</link>
      <description>&lt;p&gt;OK comments are too short for my explanation so here's the conclusion : don't use this function if you want an even randomization of your array. I wrote a snippet for the full explanation: http://snipplr.com/view/49292/beware-with-array-shuffle-function/&lt;/p&gt;</description>
      <pubDate>Sun, 20 Feb 2011 22:10:48 UTC</pubDate>
      <guid>https://ipv6.snipplr.com/view/13636/unique-random-array</guid>
    </item>
  </channel>
</rss>
