Skip to content

Latest commit

 

History

History
69 lines (50 loc) · 1.44 KB

File metadata and controls

69 lines (50 loc) · 1.44 KB

ordx

build-img pkg-img reportcard-img coverage-img version-img

Features

  • Simple API.
  • Clean and tested code.
  • Dependency-free.

Install

Go version 1.25+

go get github.com/cristalhq/ordx

Example

less := func(a, b int) bool { return a < b }
cmp := ordx.AsCmp(less)

fmt.Println(cmp(1, 2))
fmt.Println(cmp(2, 1))
fmt.Println(cmp(2, 2))

// Output:
// -1
// 1
// 0

cmp := ordx.RankCmp([]string{"low", "medium", "high"})

fmt.Println(cmp("low", "high"))
fmt.Println(cmp("high", "low"))
fmt.Println(cmp("medium", "medium"))

// Output:
// -1
// 1
// 0

See examples: example_test.go.

Documentation

See these docs.

License

MIT License.