From 58f0405c5a6b5605713f349fdd9d8ab7f9370df8 Mon Sep 17 00:00:00 2001 From: Zoee Silcock Date: Thu, 14 May 2015 17:19:31 +0200 Subject: [PATCH] Apply the random sort until the order doesn't match the current order --- src/stores/people_store.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/stores/people_store.js b/src/stores/people_store.js index 5180f54..bab2acb 100644 --- a/src/stores/people_store.js +++ b/src/stores/people_store.js @@ -39,9 +39,14 @@ var Store = Reflux.createStore({ }, onShuffle() { - this.people.sort(function(a, b) { - return 0.5 - Math.random(); - }); + var previousPeople = this.people.toString(); + + while (this.people.toString() == previousPeople) { + this.people.sort(function(a, b) { + return 0.5 - Math.random(); + }); + } + this.commitPeople(); this.trigger(); },