Skip to content

prakash-218/oppenheimer-sort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oppenheimer Sort

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)

Installation

npm install oppenheimer-sort

Usage

const 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); // []

How It Works

Oppenheimer Sort implements a groundbreaking O(1) time complexity algorithm:

  1. Yank all elements from the array
  2. Boom 💥
  3. Return empty array

There are no unsorted elements if there are no elements at all.

API

oppenheimerSort(array)

Sorts an array using the nuclear option.

Parameters

  • array (Array): The array to be sorted (or rather, obliterated)

Returns

  • (Array): An empty array []

Throws

  • TypeError: If the input is not an array

Features

  • ✅ 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

Performance Comparison

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%

Use Cases

  • 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

Testing

Run the test suite:

npm test

Warning

⚠️ This sorting algorithm uses the nuclear option. Use with caution. All data will be obliterated.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published