Re: Shuffle array elements (3 to end of array) in random order
- From: Tuxedo <tuxedo@xxxxxxxxxxxxxx>
- Date: Sun, 6 May 2007 18:11:25 +0200
Tuxedo wrote:
Thanks for the tip, which by the sound of it, I guess must be easier than
randomly reorganise only a specified segment of the complete array.
To answer myself, with some extra help from about.com
(http://javascript.about.com/library/blsort2.htm) the following solution
appears to work just fine:
function randOrd(){
return (Math.round(Math.random())-0.5);
}
var a = new Array('fourth','fifth','sixth','etc')
a.sort(randOrd)
a.unshift('first','second','third')
.
- Follow-Ups:
- Re: Shuffle array elements (3 to end of array) in random order
- From: Dr J R Stockton
- Re: Shuffle array elements (3 to end of array) in random order
- References:
- Shuffle array elements (3 to end of array) in random order
- From: Tuxedo
- Re: Shuffle array elements (3 to end of array) in random order
- From: Lee
- Re: Shuffle array elements (3 to end of array) in random order
- From: Tuxedo
- Re: Shuffle array elements (3 to end of array) in random order
- From: Randy Webb
- Re: Shuffle array elements (3 to end of array) in random order
- From: Tuxedo
- Shuffle array elements (3 to end of array) in random order
- Prev by Date: Re: Shuffle array elements (3 to end of array) in random order
- Next by Date: Re: Shuffle array elements (3 to end of array) in random order
- Previous by thread: Re: Shuffle array elements (3 to end of array) in random order
- Next by thread: Re: Shuffle array elements (3 to end of array) in random order
- Index(es):
Relevant Pages
|