MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/i7mab9/so_amazing/g12r78k/
r/ProgrammerHumor • u/SBG_Mujtaba • Aug 11 '20
137 comments sorted by
View all comments
0
[deleted] — view deleted comment
29 u/SBG_Mujtaba Aug 11 '20 It's is a pretty new idea, but what about not sorting! 3 u/mohragk Aug 11 '20 const arr = [4,2,7,4,3,7,3,12,7]let delay = 1arr.map((item) => {setTimeout( () => {console.log(item)},delay++)}) 1 u/Noch_ein_Kamel Aug 11 '20 Just create a random delay and use that delay in all setTimeout calls.bonus: if you want to randomize your array just move the random number creation inside the loop 1 u/mohragk Aug 11 '20 Just increase the delay by one for each element. Or, you know, don't use setTimeOut(); 1 u/[deleted] Aug 11 '20 ...then don't sort at all?
29
It's is a pretty new idea, but what about not sorting!
3
const arr = [4,2,7,4,3,7,3,12,7]
let delay = 1
arr.map((item) => {setTimeout( () => {console.log(item)},delay++)})
1
Just create a random delay and use that delay in all setTimeout calls.
bonus: if you want to randomize your array just move the random number creation inside the loop
Just increase the delay by one for each element. Or, you know, don't use setTimeOut();
...then don't sort at all?
View all comments
0
u/[deleted] Aug 11 '20
[deleted] — view deleted comment