Curiosity cabinet · Beginner
Sleep Sort
Schedule one timer per value and emit values as their timers wake.
- Best
- O(n) setup
- Average
- O(max value) wait
- Worst
- Scheduler-dependent
- Space
- O(n)
- Stability
- Not stable
- Memory model
- Uses auxiliary storage
How it builds order
- Create a timer for each nonnegative value.
- Use a delay proportional to that value.
- Emit values as callbacks wake.
- Observe scheduler and scaling limitations.
Why it works
If timers wake perfectly in delay order, smaller values emit first—an assumption real schedulers do not guarantee precisely.
Watch for: This is a concurrency demonstration, not a dependable comparison sort.
The interactive version of this page adds the full trace, synchronized pseudocode, practice decisions, input experiments, and mastery review.