diff --git a/clusters-pre b/clusters-pre index 08db070..015f3d2 100644 --- a/clusters-pre +++ b/clusters-pre @@ -40,6 +40,18 @@ function createFace(faceId, photoId) { return div; } +function shuffle(array) { + var i = array.length, tmp, random; + while (i > 0) { + random = Math.floor(Math.random() * i); + i--; + tmp = array[i]; + array[i] = array[random]; + array[random] = tmp; + } + return array; +} + document.addEventListener("DOMContentLoaded", (event) => { var div = document.createElement("div"); div.textContent = "There are " + clusters.length + " clusters."; @@ -57,6 +69,8 @@ document.addEventListener("DOMContentLoaded", (event) => { div.innerHTML = html; clusterBlock.appendChild(div); + shuffle(cluster); + cluster.forEach((tuple, index) => { if (index >= 10) { return;