Installation
pnpm add @kktestdev/kksort
npm i @kktestdev/kksort
yarn add @kktestdev/kksortUse subpath imports for smallest bundles, or import grouped modules when you need many algorithms.
@kktestdev/kksort
A lightweight TypeScript library that ships 6 sorting algorithms and 4 searching algorithms with tree-shakable imports. This page summarizes installation, practical strengths, and caveats based on the npm package details.
pnpm add @kktestdev/kksort
npm i @kktestdev/kksort
yarn add @kktestdev/kksortUse subpath imports for smallest bundles, or import grouped modules when you need many algorithms.
import { quickSort } from "@kktestdev/kksort/quick-sort";
import { binarySearch } from "@kktestdev/kksort/binary";
import { mergeSort, heapSort } from "@kktestdev/kksort/sort";
import { linearSearch, jumpSearch } from "@kktestdev/kksort/search";| Sort | Best / Avg / Worst | Stable | Use Case |
|---|---|---|---|
| Bubble Sort | O(n) / O(n^2) / O(n^2) | ✅ | Learning, tiny arrays |
| Insertion Sort | O(n) / O(n^2) / O(n^2) | ✅ | Nearly sorted data |
| Selection Sort | O(n^2) / O(n^2) / O(n^2) | ❌ | Low write count |
| Merge Sort | O(n log n) / O(n log n) / O(n log n) | ✅ | Stable output needed |
| Quick Sort | O(n log n) / O(n log n) / O(n^2) | ❌ | General purpose |
| Heap Sort | O(n log n) / O(n log n) / O(n log n) | ❌ | Worst-case safety |
| Search | Best / Avg / Worst | Requirement |
|---|---|---|
| Binary Search | O(1) / O(log n) / O(log n) | Sorted input |
| Linear Search | O(1) / O(n) / O(n) | Unsorted is fine |
| Jump Search | O(1) / O(sqrt(n)) / O(sqrt(n)) | Sorted input |
| Quick Search | O(1) / O(n) / O(n^2) | Mutates working array |