To sort an array in JavaScript, we can do like:
let myArr = [5,3,11,-1,-3,55,2,12,31,87,99];
myArr.sort((a,b) => a-b);
console.log(myArr);
but how do we sort a Set? for example if I have
let mySet = new Set();
for(let i=0; i<100; i++){
mySet.add(Math.round(Math.random() * 50));
}
Is there any native function of the sort myArr.sort()
which I can use to sort this set?