Standard library / sort
sort.IntSlice.Less()
Reports whether the element at i precedes the element at j. Indices must be valid. Expected stdout: 'true false\n'.
Formal Syntax & Structure
go syntaxgo
func (x IntSlice) Less(i, j int) boolParameters & Attributes
| Name | Type | Description |
|---|---|---|
| i | int | Index or start position. |
| j | int | Second index or exclusive end position. |
Return Value
bool
Reports whether the element at i precedes the element at j. Indices must be valid.
Working Example
Example Snippetgo
package main
import ( "fmt" "sort")
func main() { a := sort.IntSlice([]int{1, 2, 3}) fmt.Println(a.Less(0, 1), a.Less(1, 0))}