@kktestdev/kksort

Type-Safe Sorting And Search Toolkit

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.

TypeScript 5.3+Tree-ShakableZero DependenciesProduction Ready

Installation

pnpm add @kktestdev/kksort
npm i @kktestdev/kksort
yarn add @kktestdev/kksort

Use subpath imports for smallest bundles, or import grouped modules when you need many algorithms.

Import Patterns

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";

Pros And Trade-Offs

Advantages

  • - Type-safe API with TypeScript generics
  • - Tree-shakable subpath imports for small bundles
  • - Zero runtime dependencies
  • - Includes 6 sorting + 4 searching algorithms
  • - Comparator support for numbers, strings, and objects
  • - Lightweight package footprint with production-ready docs

Cautions

  • - Binary Search and Jump Search require sorted input
  • - Quick Search mutates the working array during execution
  • - Bubble/Insertion/Selection are slower on large datasets
  • - Quick Sort can degrade to O(n^2) in worst pivot scenarios
  • - Stable ordering is guaranteed only for stable algorithms

Algorithm Snapshot

SortBest / Avg / WorstStableUse Case
Bubble SortO(n) / O(n^2) / O(n^2)Learning, tiny arrays
Insertion SortO(n) / O(n^2) / O(n^2)Nearly sorted data
Selection SortO(n^2) / O(n^2) / O(n^2)Low write count
Merge SortO(n log n) / O(n log n) / O(n log n)Stable output needed
Quick SortO(n log n) / O(n log n) / O(n^2)General purpose
Heap SortO(n log n) / O(n log n) / O(n log n)Worst-case safety
SearchBest / Avg / WorstRequirement
Binary SearchO(1) / O(log n) / O(log n)Sorted input
Linear SearchO(1) / O(n) / O(n)Unsorted is fine
Jump SearchO(1) / O(sqrt(n)) / O(sqrt(n))Sorted input
Quick SearchO(1) / O(n) / O(n^2)Mutates working array