putin-sort
v1.0.0
Published
The most stable sorting algorithm. Elements that disagree with the order simply... disappear.
Downloads
103
Maintainers
Readme
putin-sort
The most stable sorting algorithm. Elements that disagree with the order simply... disappear.
A meme sorting algorithm inspired by real-world political elimination patterns. Instead of comparing and swapping, Putin Sort removes elements until whatever remains is in order.
Features
- Weighted targeting — elements out of order (opponents) are more likely to be removed, but elements in order (allies) are also at risk
- Paranoia level — controls how aggressively allies get purged (even a sorted array isn't safe)
- Realistic elimination methods — defenestration, polonium, novichok, plane crashes, mysterious illness, prison, exile...
- Proximity to power — elements near the beginning of the array are at higher risk
- Ally betrayal tracking — the elimination log shows which victims were already in the right position
- Replace mode — fills vacancies with loyal duplicates (like real life!)
- Approval rating — always between 95% and 100%
Install
npm install putin-sort
# or
bun add putin-sortUsage
import { putinSort } from "putin-sort";
const result = putinSort([5, 3, 1, 4, 2]);
// [PUTIN SORT] Sorting 5 elements. Stability will be maintained.
// [PUTIN SORT] 3: fell from a hospital window during a routine checkup.
// [PUTIN SORT] 5: was aboard a plane that experienced a rapid unscheduled disassembly.
// [PUTIN SORT] 4: committed suicide with two shots to the back of the head.
// [PUTIN SORT] Regime stabilized. 3/5 elements removed.
// [PUTIN SORT] 0 of those were allies. Trust no one.
// [PUTIN SORT] 2 elements remain. Approval rating: 97.3%
console.log(result.sorted); // [1, 2]
console.log(result.eliminated); // Full elimination log with methodsOptions
putinSort(array, {
propaganda: true, // Log to console (default: true)
direction: "asc", // "asc" or "desc" (default: "asc")
paranoia: 5, // 0-10, higher = allies also get purged (default: 5)
replace: false, // Fill vacancies with loyal duplicates (default: false)
});Dramatic Mode (async)
import { putinSortDramatic } from "putin-sort";
// Same as putinSort, but with dramatic pauses between eliminations
const result = await putinSortDramatic([5, 3, 1, 4, 2], {
delayMs: 800,
});Special Operations
Prigozhin Special
When an ally gets too powerful, they get eliminated along with everyone near them.
import { prigozhinSpecial } from "putin-sort";
prigozhinSpecial([1, 2, 99, 3, 4]);
// [PUTIN SORT] Element 99 got too ambitious. Plane crash imminent.
// [PUTIN SORT] 2, 99, 3 — all aboard the same flight. Tragic.
// → [1, 4]Annexation
Take elements from another array. They "voted" to join.
import { annex } from "putin-sort";
annex([1, 2, 3], [4, 5, 6, 7]);
// [PUTIN SORT] Referendum held: 3/4 elements voted to join. (97.2% approval)
// → [1, 2, 3, 4, 5, 6]Special Military Operation
The nuclear option.
import { specialMilitaryOperation } from "putin-sort";
specialMilitaryOperation([1, 2, 3, 4, 5]);
// [PUTIN SORT] Special military sorting operation initiated.
// [PUTIN SORT] All 5 elements have been liberated from existence.
// → []Complexity Analysis
| Metric | Value | |--------|-------| | Time | O(n) — very efficient, no complaints | | Space | O(1) — elements simply cease to exist | | Stability | Absolute. Do not question it. | | Correctness | The result is always correct. Always. | | Approval Rating | 95-100% |
Elimination Methods
| Method | Probability | |--------|------------| | Defenestration | 25% | | Plane crash | 15% | | Sudden illness | 15% | | Polonium-210 | 10% | | Novichok | 10% | | Prison | 10% | | Exile | 5% | | Suicide (two shots) | 5% | | Helicopter accident | 3% | | Car bomb | 2% |
Disclaimer
This is a satirical/meme package. It is commentary on authoritarian methods, not an endorsement. No actual elements were harmed in the making of this package (well, some were).
License
MIT
