Standard library / sort

sort.SearchStrings()

Returns the first index at which the target can be inserted in an ascending sorted slice. Check equality separately for membership. Expected stdout: '1 3\n'.

Formal Syntax & Structure

go syntaxgo
func SearchStrings(a []string, x string) int

Parameters & Attributes

NameTypeDescription
a[]stringSorted input slice.
xstringInput value or collection to process.

Return Value

int

Returns the first index at which the target can be inserted in an ascending sorted slice. Check equality separately for membership.

Working Example

Example Snippetgo
package main
import (  "fmt"  "sort")
func main() {  fmt.Println(sort.SearchStrings([]string{"a", "b", "c"}, "b"), sort.SearchStrings([]string{"a", "b", "c"}, "z"))}
Go Reference