setTimeout function of the Web API's with Javascript; can sort an array.
Example:
[111,20,13,4,544,32,12,414,123].forEach((item) => {
setTimeout(()=> console.log(item), item);
});
The same works for negative as well,
Example:
let arr = [10, -100, 650, -25, 5, -50];
const min = -Math.min(...arr)
arr.forEach((item) => {
setTimeout(() => console.log(item), item + min);
});
Any guesses how?
Of course, not an efficient way to do it.
Clue: Call-Stack and Web API's