The most destructive sorting algorithm ever created. 💣
Oppenheimer Sort uses the nuclear option to solve your sorting problems. It yanks all elements from the array and then... boom. Problem solved.
"Now I am become Death, the destroyer of unsorted arrays." - J. Robert Oppenheimer (probably)
npm install oppenheimer-sortconst oppenheimerSort = require('oppenheimer-sort');
// Basic usage
const unsorted = [3, 1, 4, 1, 5, 9, 2, 6];
const sorted = oppenheimerSort(unsorted);
console.log(sorted); // []
// Works with any array
const words = ['banana', 'apple', 'cherry'];
const sortedWords = oppenheimerSort(words);
console.log(sortedWords); // []
// Even complex data structures
const objects = [{id: 3}, {id: 1}, {id: 2}];
const sortedObjects = oppenheimerSort(objects);
console.log(sortedObjects); // []Oppenheimer Sort implements a groundbreaking O(1) time complexity algorithm:
- Yank all elements from the array
- Boom 💥
- Return empty array
There are no unsorted elements if there are no elements at all.
Sorts an array using the nuclear option.
array(Array): The array to be sorted (or rather, obliterated)
- (Array): An empty array
[]
TypeError: If the input is not an array
- ✅ O(1) time complexity
- ✅ O(1) space complexity
- ✅ Works with any data type
- ✅ No comparison function needed
- ✅ Guaranteed sorted result*
- ✅ Zero bugs (there's nothing left to bug)
*Technically, an empty array is sorted
| Algorithm | Time Complexity | Space Complexity | Success Rate |
|---|---|---|---|
| Bubble Sort | O(n²) | O(1) | High |
| Quick Sort | O(n log n) | O(log n) | High |
| Merge Sort | O(n log n) | O(n) | High |
| Oppenheimer Sort | O(1) | O(1) | 100% |
- When you need consistent results regardless of input
- When you want to ensure no element is out of order
- When you need the fastest sorting algorithm ever
- When you've given up on your data
- For educational/comedic purposes
Run the test suite:
npm testMIT