// Sort a slice in descending order by a field name.
18787
func DescByField(slice interface{}, name string) {
	New(slice, FieldGetter(name), Descending).Sort()
}
1146284
func (s *ScrollService) Sort(field string, ascending bool) *ScrollService {
	s.ss = s.ss.Sort(field, ascending)
	return s
}
1218453
func Sorting(field sortingField, order sortingOrder) QueryOpt {
	return QueryOpt{func(o *QueryOptions) {
		o.SortField = field
		o.SortOrder = order
	}}
}
530328
func (s *CatCountService) Sort(fields ...string) *CatCountService {
	s.sort = fields
	return s
}
473964
func (f Fields) SortedEntries() (s []*FieldEntry) {
	if len(f) == 0 {
		return nil
	}
	s = make([]*FieldEntry, 0, len(f))
	for k, v := range f {
		s = append(s, &FieldEntry{k, v})
	}
	sort.Sort(fieldEntrySlice(s))
	return
}
322655
func (ns Nodes) Sort(o NodeOrder) error {
	var s nodeSorter

	switch o {
	case FlatNameOrder:
		s = nodeSorter{ns,
			func(l, r *Node) bool {
				if iv, jv := abs64(l.Flat), abs64(r.Flat); iv != jv {
					return iv > jv
				}
				if iv, jv := l.Info.PrintableName(), r.Info.PrintableName(); iv != jv {
					return iv < jv
				}
				if iv, jv := abs64(l.Cum), abs64(r.Cum); iv != jv {
					return iv > jv
				}
				return compareNodes(l, r)
			},
		}
	case FlatCumNameOrder:
		s = nodeSorter{ns,
			func(l, r *Node) bool {
				if iv, jv := abs64(l.Flat), abs64(r.Flat); iv != jv {
					return iv > jv
				}
				if iv, jv := abs64(l.Cum), abs64(r.Cum); iv != jv {
					return iv > jv
				}
				if iv, jv := l.Info.PrintableName(), r.Info.PrintableName(); iv != jv {
					return iv < jv
				}
				return compareNodes(l, r)
			},
		}
	case NameOrder:
		s = nodeSorter{ns,
			func(l, r *Node) bool {
				if iv, jv := l.Info.Name, r.Info.Name; iv != jv {
					return iv < jv
				}
				return compareNodes(l, r)
			},
		}
	case FileOrder:
		s = nodeSorter{ns,
			func(l, r *Node) bool {
				if iv, jv := l.Info.File, r.Info.File; iv != jv {
					return iv < jv
				}
				if iv, jv := l.Info.StartLine, r.Info.StartLine; iv != jv {
					return iv < jv
				}
				return compareNodes(l, r)
			},
		}
	case AddressOrder:
		s = nodeSorter{ns,
			func(l, r *Node) bool {
				if iv, jv := l.Info.Address, r.Info.Address; iv != jv {
					return iv < jv
				}
				return compareNodes(l, r)
			},
		}
	case CumNameOrder, EntropyOrder:
		// Hold scoring for score-based ordering
		var score map[*Node]int64
		scoreOrder := func(l, r *Node) bool {
			if iv, jv := abs64(score[l]), abs64(score[r]); iv != jv {
				return iv > jv
			}
			if iv, jv := l.Info.PrintableName(), r.Info.PrintableName(); iv != jv {
				return iv < jv
			}
			if iv, jv := abs64(l.Flat), abs64(r.Flat); iv != jv {
				return iv > jv
			}
			return compareNodes(l, r)
		}

		switch o {
		case CumNameOrder:
			score = make(map[*Node]int64, len(ns))
			for _, n := range ns {
				score[n] = n.Cum
			}
			s = nodeSorter{ns, scoreOrder}
		case EntropyOrder:
			score = make(map[*Node]int64, len(ns))
			for _, n := range ns {
				score[n] = entropyScore(n)
			}
			s = nodeSorter{ns, scoreOrder}
		}
	default:
		return fmt.Errorf("report: unrecognized sort ordering: %d", o)
	}
	sort.Sort(s)
	return nil
}
675890
func (api *CDROMAPI) SortByName(reverse bool) *CDROMAPI {
	api.sortByName(reverse)
	return api
}
1350895
func (r *ReindexSource) Sort(field string, ascending bool) *ReindexSource {
	r.request = r.request.Sort(field, ascending)
	return r
}
9451
func (api *DiskAPI) SortBy(key string, reverse bool) *DiskAPI {
	api.sortBy(key, reverse)
	return api
}
1105535
func (api *ZoneAPI) SortByName(reverse bool) *ZoneAPI {
	api.sortByName(reverse)
	return api
}
236248
func (api *ProxyLBAPI) SortByName(reverse bool) *ProxyLBAPI {
	api.sortByName(reverse)
	return api
}
731312
func (api *SimpleMonitorAPI) SortByName(reverse bool) *SimpleMonitorAPI {
	api.sortByName(reverse)
	return api
}
169330
func (v Versions) Sort() {
	sort.Slice(v, func(i, j int) bool {
		return v[i].NewerThan(v[j])
	})
}
167178
func Sort(data Interface) {
	n := data.Len()
	if fs, ok := data.(*funcs); ok {
		quickSort_func(fs.lessSwap, 0, n, maxDepth(n))
	} else {
		quickSort(data, 0, n, maxDepth(n))
	}
}
1269168
func SliceToLower(s []string) []string {
	if s == nil {
		return nil
	}

	l := make([]string, len(s))
	for i, v := range s {
		l[i] = strings.ToLower(v)
	}

	return l
}
332947
func (c symbolSlice) sort() symbolSlice {
	sort.Slice(c, func(i, j int) bool { return c[i].offset < c[j].offset })
	return c
}
695014
func (d *ClientDigestsFile) Sort() {
	sort.Slice(d.entries, func(i, j int) bool {
		l, r := d.entries[i], d.entries[j]
		if l.plat != r.plat {
			return l.plat < r.plat
		}
		return l.ref.HashAlgo > r.ref.HashAlgo // more recent algos first
	})
}