Skip to content

A sorting algorithm implemented purely using TypeScript types

License

Notifications You must be signed in to change notification settings

Jcparkyn/type-sort

Repository files navigation

type-sort

This is a sorting algorithm implemented using only TypeScript types. Note: requires TypeScript 4.7.0 or newer.

Try the live demo in the TypeScript Playground.

type SortedThings = Sorted<[0, 8, -7, -3e7, 1337, 5, 3, 4]>
// SortedThings has type of [-30000000, -7, 0, 3, 4, 5, 8, 1337]

FAQ

Q. Does this actually work?

A. Yes, but only for tuples up to around 90 elements long, containing integers between -1021 and 1021.

Q. Why would I ever want to use this?

A. Uhh... science?

Credits

This implementation uses GreaterThan from type-plus to perform comparisons between numbers.

About

A sorting algorithm implemented purely using TypeScript types

Topics

Resources

License

Stars

Watchers

Forks