You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hello dear frineds
im trying to shuffle MapSchema but it automaticly sorting list by key
here is my code:
let shuffleKeys = [];
this.players.forEach((player, key) => {
shuffleKeys.push(key);
});
shuffleKeys = H.shuffle(shuffleKeys); // here shuffled int array succesfully
let shuffledPlayers = new MapSchema();
for (let i = 0; i < shuffleKeys.length; i++) {
shuffledPlayers.set("" + shuffleKeys[i], this.players.get("" + shuffleKeys[i]));
}
this.players = shuffledPlayers;
The text was updated successfully, but these errors were encountered:
Maps aren't really supposed to be ordered. Javascript maps do maintain order, at least in newer versions, but that is dangerous behavior to rely on. Use an array to maintain order.
hello dear frineds
im trying to shuffle MapSchema but it automaticly sorting list by key
here is my code:
let shuffleKeys = [];
this.players.forEach((player, key) => {
shuffleKeys.push(key);
});
shuffleKeys = H.shuffle(shuffleKeys); // here shuffled int array succesfully
let shuffledPlayers = new MapSchema();
for (let i = 0; i < shuffleKeys.length; i++) {
shuffledPlayers.set("" + shuffleKeys[i], this.players.get("" + shuffleKeys[i]));
}
this.players = shuffledPlayers;
The text was updated successfully, but these errors were encountered: