js 乱序

all=['H1','H2','H3','H4','H5','H6','H7','H8','H9','H10','H11','H12','H13',
			    'R1','R2','R3','R4','R5','R6','R7','R8','R9','R10','R11','R12','R13',
				'M1','M2','M3','M4','M5','M6','M7','M8','M9','M10','M11','M12','M13',
				'F1','F2','F3','F4','F5','F6','F7','F8','F9','F10','F11','F12','F13'
				];
				
			//乱序算法1 from www  不够乱 放弃
            function randomsort(a, b) {
				return Math.random()>.5 ? -1 : 1;
			}
			//乱序算法2 from www 思路和我的一样
			function arrayShuffle(arr){
				var result = [],
					len = arr.length;
				while(len--){
					result[result.length] = arr.splice(Math.floor(Math.random()*(len+1)),1);
				}
				return result;
			}

 

你可能感兴趣的:(算法)