Skip to main content

Tedshd's Dev note

JavaScript - Random Array Sort

Table of Contents

# JavaScript - Random Array Sort

function randOrd(){
	return (Math.round(Math.random())-0.5);
}

anyArray = [1, 's', 3, 'arr', 4];
anyArray.sort( randOrd );
alert(anyArray);

Refer - Random Array Sort