order

package
v0.8.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2022 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package order provides helper functions and contraints to allow ordering streams

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IgnoreCase

func IgnoreCase(a, b string) int

IgnoreCase implements order.Comparator for strings, ignoring the case.

func Int

func Int[T constraints.Integer](a, b T) int

Int implements the Comparator for signed integers. This will be usually faster than Natural comparator

func Natural

func Natural[T constraints.Ordered](a, b T) int

Natural implements the Comparator for those elements whose type has a natural order (numbers and strings)

func SortSlice

func SortSlice[T any](slice []T, comparator Comparator[T])

SortSlice sorts the given slice according to the criteria in the provided comparator

Types

type Comparator

type Comparator[T any] func(a, b T) int

Comparator function compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

func ByKey

func ByKey[K comparable, V any](cmp Comparator[K]) Comparator[item.Pair[K, V]]

ByKey uses the source comparator to compare the key of two item.Pair entries

func ByVal

func ByVal[K, V comparable](cmp Comparator[V]) Comparator[item.Pair[K, V]]

ByVal uses the source comparator to compare the value of two item.Pair entries

func Inverse

func Inverse[T any](cmp Comparator[T]) Comparator[T]

Inverse result of the Comparator function for inverted sorts

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL