Documentation ¶
Overview ¶
The sort package provides primitives for sorting arrays and user-defined collections.
Index ¶
- func FloatsAreSorted(a []float) bool
- func IntsAreSorted(a []int) bool
- func IsSorted(data Interface) bool
- func Sort(data Interface)
- func SortFloats(a []float)
- func SortInts(a []int)
- func SortStrings(a []string)
- func StringsAreSorted(a []string) bool
- type FloatArray
- type IntArray
- type Interface
- type StringArray
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FloatsAreSorted ¶
func FloatsAreSorted(a []float) bool
FloatsAreSorted tests whether an array of floats is sorted in increasing order.
func IntsAreSorted ¶
IntsAreSorted tests whether an array of ints is sorted in increasing order.
func SortFloats ¶
func SortFloats(a []float)
SortFloats sorts an array of floats in increasing order.
func SortStrings ¶
func SortStrings(a []string)
SortStrings sorts an array of strings in increasing order.
func StringsAreSorted ¶
StringsAreSorted tests whether an array of strings is sorted in increasing order.
Types ¶
type FloatArray ¶
type FloatArray []float
FloatArray attaches the methods of Interface to []float, sorting in increasing order.
func (FloatArray) Len ¶
func (p FloatArray) Len() int
func (FloatArray) Less ¶
func (p FloatArray) Less(i, j int) bool
func (FloatArray) Swap ¶
func (p FloatArray) Swap(i, j int)
type IntArray ¶
type IntArray []int
IntArray attaches the methods of Interface to []int, sorting in increasing order.
type Interface ¶
type Interface interface { // Len is the number of elements in the collection. Len() int // Less returns whether the element with index i should sort // before the element with index j. Less(i, j int) bool // Swap swaps the elements with indexes i and j. Swap(i, j int) }
A type, typically a collection, that satisfies sort.Interface can be sorted by the routines in this package. The methods require that the elements of the collection be enumerated by an integer index.
type StringArray ¶
type StringArray []string
StringArray attaches the methods of Interface to []string, sorting in increasing order.
func (StringArray) Len ¶
func (p StringArray) Len() int
func (StringArray) Less ¶
func (p StringArray) Less(i, j int) bool
func (StringArray) Swap ¶
func (p StringArray) Swap(i, j int)