Skip to content

Commit

Permalink
Apply the random sort until the order doesn't match the current order
Browse files Browse the repository at this point in the history
  • Loading branch information
zoeesilcock committed May 14, 2015
1 parent fd71162 commit 58f0405
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/stores/people_store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
},
Expand Down

0 comments on commit 58f0405

Please sign in to comment.