Skip to content

cristalhq/ordx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

Comparison helpers in Go

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages