sortby

package
v0.0.0-...-678bb0e Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2017 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Overview

Package sortby provides a succinct way to generate correctly-behaved Less funcions for use with the stdlib 'sort' package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

type Chain []LessFn

Chain is a list of LessFns, each of which sorts a single aspect of your object. Nil LessFns will be ignored.

func (Chain) Use

func (c Chain) Use(i, j int) bool

Use is a sort-compatible LessFn that actually executes the full chain of comparisons.

type LessFn

type LessFn func(i, j int) bool

LessFn is the type of the function which compares element i with element j of a given slice. Unlike the stdlib sort interpretation of this function, a LessFn in sortby should only compare a single field in your datastructure's elements. Multiple LessFns can be composed with Chain to create a composite Less implementation to pass to sort.

Jump to

Keyboard shortcuts

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