Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

harlem shuffle

0 views
Skip to first unread message

Ralf Bokelberg

unread,
Jun 23, 2001, 1:04:07 PM6/23/01
to
i just found an interesting
way of shuffling an array:

function shuffle(a,b){
return random(3) - 1;
}

a = [0,1,2,3,4,5,6,7,8,9];
a.sort(shuffle);
trace(a);

--
bokel
www.bokelberg.de/actionscript
--

Tatsuo Kato

unread,
Jun 23, 2001, 1:17:18 PM6/23/01
to
Well done Ralf!

I've never thought of using a custom sort function to do that.
Can I use this one? Sure I'll add copyright :)

cheers!
TK

Ralf Bokelberg

unread,
Jun 23, 2001, 1:51:58 PM6/23/01
to
i don't know how it came in my mind -
perhaps we copyright it to some higher
lifeform from outaspace =)

--
bokel
www.bokelberg.de/actionscript
--

"Tatsuo Kato" <tuki...@ae.wakwak.com> schrieb im Newsbeitrag
news:B75AFE2D.16D43%tuki...@ae.wakwak.com...

Tatsuo Kato

unread,
Jun 23, 2001, 2:13:38 PM6/23/01
to
That can even adjust how random it should be.
eg:
---------
a.sort(function (a, b) { return random(4)-1;}); //less random
---------
a.sort(function (a, b) { return random(10)-1;}); //still less random
--------

cheers,
TK

Tatsuo Kato

unread,
Jun 23, 2001, 2:00:22 PM6/23/01
to
hehe
Might be the 666 you were possessed by the other day

cheers,

Ralf Bokelberg

unread,
Jun 23, 2001, 3:02:50 PM6/23/01
to
hehe,
sometimes a dark power
takescontrol of my mind

--
bokel
www.bokelberg.de/actionscript
--


"Tatsuo Kato" <tuki...@ae.wakwak.com> schrieb im Newsbeitrag

news:B75B0845.16D51%tuki...@ae.wakwak.com...

0 new messages