func (a *Adapter) Sort(partial string) { partialLower := strings.ToLower(partial) a.scores = make([]int, len(a.suggestions)) for i, suggestion := range a.suggestions { a.scores[i] = scoring.Score(suggestion.Name(), strings.ToLower(suggestion.Name()), partial, partialLower) } sort.Sort(a) a.DefaultAdapter.SetItems(a.suggestions) }
func (a *Adapter) Sort(partial string) { a.scores = make([]float64, len(a.suggestions)) match := []rune(partial) for i, suggestion := range a.suggestions { a.scores[i] = scoring.Score([]rune(suggestion.Name()), match) } sort.Sort(a) a.end = len(a.suggestions) for a.end > 0 && a.scores[a.end-1] == math.MaxFloat64 { a.end-- } a.DefaultAdapter.SetItems(a.suggestions[:a.end]) }