We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.
Dropsort
Jump to navigation
Jump to search
Dropsort is a highly efficient, one-pass esoteric algorithm for sorting that always returns a properly sorted list.
Description
Dropsort goes through the list dropping items from the list that are out of place. This may seem undesirable, but the reader is urged to remember that lossy algorithms like this are well-accepted in computer science; for example, the JPEG algorithm.
Algorithmic description
(In this description, list indices start at 1.)
- For each item x in the range from 2 to the length of the list
- If item x of the list is less than item x-1 on the list
- Drop item x from the list
- If item x of the list is less than item x-1 on the list
- Return the list