go/src/sort/sort.go

type Interface

// Sort sorts data in ascending order as determined by the Less method.
// It makes one call to data.Len to determine n and O(n*log(n)) calls to
// data.Less and data.Swap. The sort is not guaranteed to be stable.
//
// Note: in many situations, the newer [slices.SortFunc] function is more
// ergonomic and runs faster.
func Sort(data Interface) {}

type sortedHint

const unknownHint

const increasingHint

const decreasingHint

type xorshift

func (r *xorshift) Next() uint64 {}

func nextPowerOfTwo(length int) uint {}

type lessSwap

type reverse

// Less returns the opposite of the embedded implementation's Less method.
func (r reverse) Less(i, j int) bool {}

// Reverse returns the reverse order for data.
func Reverse(data Interface) Interface {}

// IsSorted reports whether data is sorted.
//
// Note: in many situations, the newer [slices.IsSortedFunc] function is more
// ergonomic and runs faster.
func IsSorted(data Interface) bool {}

type IntSlice

func (x IntSlice) Len() int           {}

func (x IntSlice) Less(i, j int) bool {}

func (x IntSlice) Swap(i, j int)      {}

// Sort is a convenience method: x.Sort() calls Sort(x).
func (x IntSlice) Sort() {}

type Float64Slice

func (x Float64Slice) Len() int {}

// Less reports whether x[i] should be ordered before x[j], as required by the sort Interface.
// Note that floating-point comparison by itself is not a transitive relation: it does not
// report a consistent ordering for not-a-number (NaN) values.
// This implementation of Less places NaN values before any others, by using:
//
//	x[i] < x[j] || (math.IsNaN(x[i]) && !math.IsNaN(x[j]))
func (x Float64Slice) Less(i, j int) bool {}

func (x Float64Slice) Swap(i, j int)      {}

// isNaN is a copy of math.IsNaN to avoid a dependency on the math package.
func isNaN(f float64) bool {}

// Sort is a convenience method: x.Sort() calls Sort(x).
func (x Float64Slice) Sort() {}

type StringSlice

func (x StringSlice) Len() int           {}

func (x StringSlice) Less(i, j int) bool {}

func (x StringSlice) Swap(i, j int)      {}

// Sort is a convenience method: x.Sort() calls Sort(x).
func (x StringSlice) Sort() {}

// Ints sorts a slice of ints in increasing order.
//
// Note: as of Go 1.22, this function simply calls [slices.Sort].
func Ints(x []int) {}

// Float64s sorts a slice of float64s in increasing order.
// Not-a-number (NaN) values are ordered before other values.
//
// Note: as of Go 1.22, this function simply calls [slices.Sort].
func Float64s(x []float64) {}

// Strings sorts a slice of strings in increasing order.
//
// Note: as of Go 1.22, this function simply calls [slices.Sort].
func Strings(x []string) {}

// IntsAreSorted reports whether the slice x is sorted in increasing order.
//
// Note: as of Go 1.22, this function simply calls [slices.IsSorted].
func IntsAreSorted(x []int) bool {}

// Float64sAreSorted reports whether the slice x is sorted in increasing order,
// with not-a-number (NaN) values before any other values.
//
// Note: as of Go 1.22, this function simply calls [slices.IsSorted].
func Float64sAreSorted(x []float64) bool {}

// StringsAreSorted reports whether the slice x is sorted in increasing order.
//
// Note: as of Go 1.22, this function simply calls [slices.IsSorted].
func StringsAreSorted(x []string) bool {}

// Stable sorts data in ascending order as determined by the Less method,
// while keeping the original order of equal elements.
//
// It makes one call to data.Len to determine n, O(n*log(n)) calls to
// data.Less and O(n*log(n)*log(n)) calls to data.Swap.
//
// Note: in many situations, the newer slices.SortStableFunc function is more
// ergonomic and runs faster.
func Stable(data Interface) {}