Unordered Random Numbers : <p>I have a problem. I'm trying to get 4 random numbers that will not be repeated and not ordered. For example (2,3,4,5) is not good, but (5,2,3,4) is ok.
We've implemented an algorithm but something's wrong with it.</p>

<pre><code>   var needCreate = true;
    do
    {
        var lastIndex = int.MinValue;
        for (int i = 0; i &lt; 4; i++)
        {
            thisIndex = Random.Range(0, 5);
            UnorderedIndexes.Add(thisIndex);
            if (thisIndex &lt; lastindex)
                needCreate = false;
            lastIndex = thisIndex;
        }
    }
    while (needCreate);
    foreach (int index in UnorderedIndexes)
        Debug.Log(index);
</code></pre>
