• scrion@lemmy.world
    link
    fedilink
    arrow-up
    54
    ·
    4 months ago

    The output is sorted due to the fact that for each number, a timer is started that prints out the number after waiting a number of milliseconds equal to said number.

    Therefore, 1 is printed first after delaying for 1 millisecond, 5 is printed second after 5 milliseconds etc.