Sleep Sort
async function sleepSort(arr) {
const r = [];
const promises = arr.map(
(n) =>
new Promise((resolve) =>
setTimeout(() => {
r.push(n);
resolve(null);
}, n),
),
);
await Promise.all(promises);
return r;
}
js