I was helping somebody out with his JavaScript code and my eyes were caught by a section that looked like that:
function randOrd(){
return (Math.round(Math
There is nothing wrong with it.
The function you pass to .sort() usually looks something like
function sortingFunc( first, second ) { // example: return first - second ; }
Your job in sortingFunc is to return:
The above sorting function puts things in order.
If you return -'s and +'s randomly as what you have, you get a random ordering.
Like in MySQL:
SELECT * from table ORDER BY rand()