Story Details

  • Is this the simplest (and most surprising) sorting algorithm ever? (2021)

    Posted: 2025-02-24 04:26:22

    The paper "Is this the simplest (and most surprising) sorting algorithm ever?" introduces the "Sleep Sort" algorithm, a conceptually simple, albeit impractical, sorting method. It relies on spawning a separate thread for each element to be sorted. Each thread sleeps for a duration proportional to the element's value and then outputs the element. Thus, smaller elements are outputted first, resulting in a sorted sequence. While intriguing in its simplicity, Sleep Sort's correctness depends on precise timing and suffers from significant limitations, including poor performance for large datasets, inability to handle negative or duplicate values directly, and reliance on system-specific thread scheduling. Its main contribution is as a thought-provoking curiosity rather than a practical sorting algorithm.

    Summary of Comments ( 77 )
    https://news.ycombinator.com/item?id=43155839

    Hacker News users discuss the "Mirror Sort" algorithm, expressing skepticism about its novelty and practicality. Several commenters point out prior art, referencing similar algorithms like "Odd-Even Sort" and existing work on sorting networks. There's debate about the algorithm's true complexity, with some arguing the reliance on median-finding hides significant cost. Others question the value of minimizing comparisons when other operations, like swaps or data movement, dominate the performance in real-world scenarios. The overall sentiment leans towards viewing "Mirror Sort" as an interesting theoretical exercise rather than a practical breakthrough. A few users note its potential educational value for understanding sorting network concepts.