• ScreamingFirehawk@feddit.uk
      link
      fedilink
      arrow-up
      15
      ·
      1 day ago

      It doesn’t, the array is still in the same order it started in, it’s members are just printed to the console in numerical order.

      It just prints the number 1 after 1 ms, 2 after 2 ms, 3 after 3 ms etc.

      • Randelung@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        22 hours ago

        Instead of print you could add them to a second array, though. Even clear the original first for “in place” sorting; never mind the memory allocation for the lambdas.