Use Array.sort():
numbers.sort((a, b) => a - b));
Then the array is ordered, and you can continue to the alerting. Complete code looks like this:
numbers.sort((a, b) => a - b).forEach(async numbero => {
console.alert(numbero);
})
Also - there seems to be no reason for using async
, because the function you are passing to forEach
is not async
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…