• Vinapocalypse@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    18 hours ago

    PR:

    -  setTimeout(() => console.log(item), item)
    +  setTimeout(() => console.log(item), Math.log(item))
    

    Comment: This will speed up sort time greatly. However, sort order may become erratic for longer lists, and lists with numbers less than 1

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      13
      ·
      2 days ago

      I mean, it does scale with the size of the input. Just not with the count of inputs, but rather the size of each input element.

        • Ephera@lemmy.ml
          link
          fedilink
          English
          arrow-up
          2
          ·
          2 days ago

          Oh yeah, I do think setTimeout executes in parallel, so only the largest element determines the execution time. It was difficult enough to make that sentence make sense, so I didn’t want to cram that detail in as well. 🙃