github.com/posener/order (go): Package order enables easier ordering and comparison tasks.  This package provides functionality to easily define and apply order on values. It works out of the box for most primitive types and their pointer versions, and enable order of any object using (three-way comparison) https://en.wikipedia.org/wiki/Three-way_comparison with a given `func(T, T) int` function, or by implementing the generic interface: `func (T) Compare(T) int`.  Supported Tasks:  * [x] `Sort` / `SortStable` - sort a slice.  * [x] `Search` - binary search for a value in a slice.  * [x] `MinMax` - get indices of minimal and maximal values of a slice.  * [X] `Is` - get a comparable object for more readable code.  + [x] `Select` - get the K'th greatest value of a slice.  * [x] `IsSorted` / `IsStrictSorted` - check if a slice is sorted.  Order between values can be more forgiving than strict comparison. This library allows sensible type conversions. A type `U` can be used in order function of type `T` in the following cases:  * `U` is a pointer (or pointers chain) to a `T`.  * `T` is a pointer (or pointers chain) to a `U`.  * `T` and `U` are of the same kind.  * `T` and `U` are of the same number kind group (int?, uint?, float?, complex?) and `U`'s bits number is less or equal to `T`'s bits number.  * `U` and `T` are assignable structs.  Using this library might be less type safe - because of the usage of interfaces API, and less efficient - because of the use of reflection. On the other hand, this library reduce chances for errors by providing a well tested code and more readable code. See below how some order tasks can be translated to be used by this library.  A simple example that shows how to use the order library with different basic types.  A type may implement a `func (t T) Compare(other T) int` function. In this case it could be just used with the order package functions.  An example of ordering struct with multiple fields with different priorities.
Keywords: binary-search|comparable|compare|condition|go|golang|max|min|min-max|order|partition|pivot|search|select|sort