sorting

package
v0.0.0-...-33a3eab Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NVValueSorter = Reverse(ValueSorterEx(Reverse(ByName)))
	NVNameSorter  = ValueNilSorter(ByName)
	NVSmartSorter = ValueNilSorter(ByNameSmart)
)

Functions

func ByName

func ByName(a, b string) bool

func ByNameSmart

func ByNameSmart(a, b string) bool

func Reverse

func Reverse[TElem any, TSort ~func(a, b TElem) bool](sorter TSort) TSort

Reverse a sorter (`not` the comparer)

func Sort

func Sort[TElem any, TSort ~func(a, b TElem) bool](arr []TElem, sorter TSort)

Sort an array that can be sorted by Sorter

func SortBy

func SortBy[TElem any, TBy any, TSort ~func(a, b TBy) bool](arr []TElem, sorter TSort, extractor func(obj TElem) TBy)

Sort an array of elements, by a sub-element, than be sorted by T

Types

type NameSorter

type NameSorter Sorter[string]

func ByContextual

func ByContextual() NameSorter

func ByContextualEx

func ByContextualEx(fallbackSort NameSorter) NameSorter

func ByDate

func ByDate(fallbackSort NameSorter) NameSorter

func ByDateWithContextual

func ByDateWithContextual() NameSorter

type NameValuePair

type NameValuePair struct {
	Name  string
	Value int64
}

type NameValueSorter

type NameValueSorter Sorter[NameValuePair]

func ValueNilSorter

func ValueNilSorter(sorter NameSorter) NameValueSorter

func ValueSorterEx

func ValueSorterEx(fallback NameSorter) NameValueSorter

type Sorter

type Sorter[T any] func(a, b T) bool

Jump to

Keyboard shortcuts

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