3 ms·
I thought this was going to be a silly sorting algorithm, like bogosort. So, here's my version of chronosort: Given a set of natural numbers, place them all on
by cshimmin 3y ago
I thought this was going to be a silly sorting algorithm, like bogosort.
So, here's my version of chronosort: Given a set of natural numbers, place them all on a timer, with a timeout equal to the number, and callback argument also equal to the number. The callback function simply appends its argument to the end of a shared list. At some point you will have a sorted and (eventually) complete list :)
- phreeza 3y agohttps://www.cs.princeton.edu/courses/archive/fall13/cos226/lectures/52Tries.pdf https://www.cs.princeton.edu/courses/archive/fall13/cos226/l...
- reichstein 3y agoIt is as silly as bogosort. It's queue-sort. You put the elements into a priority queue, then remove them in property order and put them into a list. Here you just use the inherent queue of a timer system, which wastes time between extracting the next element. That's silly and inefficient, and disingenuous in trying to hide the queue.
- Isognoviastoma 3y agoChronosort is closer to radix sort, as both are O(n) if values are bounded. Queue-sort (aka heapsort) is O(n log n).
- asplake 3y agoAnd with minor O(n) modifications, chronosort is fixed time too!
- eesmith 3y agoThat's called "sleepsort". For examples, https://hn.algolia.com/?q=sleepsort https://hn.algolia.com/?q=sleepsort , https://stackoverflow.com/questions/6474318/what-is-the-time-complexity-of-the-sleep-sort https://stackoverflow.com/questions/6474318/what-is-the-time... , https://stackoverflow.com/questions/74917807/is-there-any-practical-use-case-for-sleep-sort https://stackoverflow.com/questions/74917807/is-there-any-pr...