Documentation
¶
Overview ¶
This package provides a few functions to sort int arrays.
- Sort by values of another array
- Return permutation allowing to sort input array (like R order() function)
Inspired from https://stackoverflow.com/questions/42707252/
Index ¶
- func Intersect(slice1, slice2 []int) []int
- func Jacquard(slice1, slice2 []int) float64
- func OrderInt(values []int, decreasing bool) []int
- func SortIndicesByValues(values []float64) []int
- func SortIntBy(toSort []int, byValues []int, decreasing bool)
- func Union(slice1, slice2 []int) []int
- func UnionStr(slice1, slice2 []string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Intersect ¶
This function returns the intersection of two slices of ints, considered as sets (i.e. it is the slice of the values that are present in both slices)
func Jacquard ¶
This function returns the jacquard similarity between two slices of ints, considered as sets (i.e. it is the size of the intersection divided by the size of the union)
func OrderInt ¶
Returns reordered indices (permutation) by values (like order() R function). It may be in decreasing order.
Example:
input := []int{10,20,30,80,50}
output := OrderInt(input) // {0,1,2,4,3}
// To iterate over the sorted array :
for _,ord := range output {
input[ord]
}
func SortIndicesByValues ¶
sortIndicesByValues returns indices sorted by their corresponding values in ascending order
func SortIntBy ¶
Sorts "toSort" array according to "byValues" Array.
- "toSort" array is modified after the function.
- "byValues" array is not modified.
The sort may be in decreasing order.
Types ¶
This section is empty.