// Sort the values in s.Slice by retrieving comparison items using
// s.Getter(s.Slice). A runtime panic will occur if s.Getter is not applicable
// to s.Slice, or if the values retrieved by s.Getter can't be compared, i.e.
// are unrecognized types.
502151
func (s *Sorter) Sort() {
	if s.Slice.Len() < 2 {
		// Nothing to sort
		return
	}
	if s.Getter == nil {
		s.Getter = SimpleGetter()
	}
	s.itemType = s.Slice.Index(0).Type()
	s.vals = s.Getter(s.Slice)
	one := s.vals[0]
	s.valType = one.Type()
	s.valKind = one.Kind()
	switch s.valKind {
	// If the value isn't a standard kind, find a known type to sort by
	default:
		switch s.valType {
		default:
			panic(fmt.Sprintf("Cannot sort by type %v", s.valType))
		case t_time:
			switch s.Ordering {
			default:
				panic(fmt.Sprintf("Invalid ordering %v for time.Time", s.Ordering))
			case Ascending:
				sort.Sort(timeAscending{s})
			case Descending:
				sort.Sort(timeDescending{s})
			}
		}
	// Strings
	case reflect.String:
		switch s.Ordering {
		default:
			panic(fmt.Sprintf("Invalid ordering %v for strings", s.Ordering))
		case Ascending:
			sort.Sort(stringAscending{s})
		case Descending:
			sort.Sort(stringDescending{s})
		case CaseInsensitiveAscending:
			sort.Sort(stringInsensitiveAscending{s})
		case CaseInsensitiveDescending:
			sort.Sort(stringInsensitiveDescending{s})
		}
	// Booleans
	case reflect.Bool:
		switch s.Ordering {
		default:
			panic(fmt.Sprintf("Invalid ordering %v for booleans", s.Ordering))
		case Ascending:
			sort.Sort(boolAscending{s})
		case Descending:
			sort.Sort(boolDescending{s})
		}
	// Ints
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		switch s.Ordering {
		default:
			panic(fmt.Sprintf("Invalid ordering %v for ints", s.Ordering))
		case Ascending:
			sort.Sort(intAscending{s})
		case Descending:
			sort.Sort(intDescending{s})
		}
	// Uints
	case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
		switch s.Ordering {
		default:
			panic(fmt.Sprintf("Invalid ordering %v for uints", s.Ordering))
		case Ascending:
			sort.Sort(uintAscending{s})
		case Descending:
			sort.Sort(uintDescending{s})
		}
	// Floats
	case reflect.Float32, reflect.Float64:
		switch s.Ordering {
		default:
			panic(fmt.Sprintf("Invalid ordering %v for floats", s.Ordering))
		case Ascending:
			sort.Sort(floatAscending{s})
		case Descending:
			sort.Sort(floatDescending{s})
		}
	}
}
1260777
func (p Params) Slices() Params {
	var result Params
	for i := range p {
		if p[i].IsSlice {
			result = append(result, p[i])
		}
	}
	return result
}
666486
func Slice(list, start, end cty.Value) (cty.Value, error) {
	return SliceFunc.Call([]cty.Value{list, start, end})
}
702621
func CompareValues(v1, v2 Value) int {
	switch v1 := v1.(type) {
	case Document:
		v2, ok := v2.(Document)
		if !ok {
			return -1
		} else if len(v1) != len(v2) {
			return len(v1) - len(v2)
		}
		return -1 // TODO: implement proper sorting?
	case Strings:
		v2, ok := v2.(Strings)
		if !ok {
			return -1
		} else if len(v1) != len(v2) {
			return len(v1) - len(v2)
		}
		for i := range v1 {
			if dn := CompareValues(String(v1[i]), String(v2[i])); dn != 0 {
				return dn
			}
		}
		return 0
	case Bytes:
		v2, ok := v2.(Bytes)
		if !ok {
			return -1
		}
		return bytes.Compare(v1, v2)
	case Time:
		v2, ok := v2.(Time)
		if !ok {
			return -1
		}
		t1, t2 := time.Time(v1), time.Time(v2)
		if t1.Equal(t2) {
			return 0
		} else if t1.Before(t2) {
			return -1
		}
		return +1
	case String:
		v2, ok := v2.(String)
		if !ok {
			return -1
		}
		return strings.Compare(string(v1), string(v2))
	case Int:
		v2, ok := v2.(Int)
		if !ok {
			return -1
		}
		if v1 == v2 {
			return 0
		} else if v1 < v2 {
			return -1
		}
		return +1
	case Float:
		v2, ok := v2.(Float)
		if !ok {
			return -1
		}
		if v1 == v2 {
			return 0
		} else if v1 < v2 {
			return -1
		}
		return +1
	}
	return -1
}
984680
func (me *DefaultAdapter) SliceValueSql(buf *SqlBuilder, slice reflect.Value) error {
	buf.WriteRune(left_paren_rune)
	for i, l := 0, slice.Len(); i < l; i++ {
		if err := me.Literal(buf, slice.Index(i).Interface()); err != nil {
			return err
		}
		if i < l-1 {
			buf.WriteRune(comma_rune)
			buf.WriteRune(space_rune)
		}
	}
	buf.WriteRune(right_paren_rune)
	return nil
}
164457
func (c *Scratch) GetSortedMapValues(key string) interface{} {
	c.mu.RLock()

	if c.values[key] == nil {
		c.mu.RUnlock()
		return nil
	}

	unsortedMap := c.values[key].(map[string]interface{})
	c.mu.RUnlock()
	var keys []string
	for mapKey := range unsortedMap {
		keys = append(keys, mapKey)
	}

	sort.Strings(keys)

	sortedArray := make([]interface{}, len(unsortedMap))
	for i, mapKey := range keys {
		sortedArray[i] = unsortedMap[mapKey]
	}

	return sortedArray
}
213884
func (s *CatAliasesService) Sort(fields ...string) *CatAliasesService {
	s.sort = fields
	return s
}
192643
func (list *List) GetValue() interface{} {
	var values []interface{}
	for _, val := range list.values {
		values = append(values, val.GetValue())
	}
	return values
}
966175
func sortKeys(vals map[string]counter) (keys []string) {
	for k := range vals {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	return keys
}
540966
func (c *Client) GetValues(keys []string) (map[string]string, error) {
	vars := make(map[string]string)
	for _, key := range keys {
		resp, err := c.client.Get(context.Background(), key, &client.GetOptions{
			Recursive: true,
			Sort:      true,
			Quorum:    true,
		})
		if err != nil {
			return vars, err
		}
		err = nodeWalk(resp.Node, vars)
		if err != nil {
			return vars, err
		}
	}
	return vars, nil
}
1031851
func sortListings(listings Listings, options ListOptions) {
	comparisonFunction := listings.lessByName
	if options.sortTime {
		comparisonFunction = listings.lessByTime
	} else if options.sortSize {
		comparisonFunction = listings.lessBySize
	}

	sort.Slice(listings, comparisonFunction)

	if options.sortReverse {
		middleIndex := (len(listings) / 2)
		if len(listings)%2 == 0 {
			middleIndex--
		}

		for i := 0; i <= middleIndex; i++ {
			frontIndex := i
			rearIndex := len(listings) - 1 - i

			if frontIndex == rearIndex {
				break
			}

			tmp := listings[frontIndex]
			listings[frontIndex] = listings[rearIndex]
			listings[rearIndex] = tmp
		}
	}
}
899022
func SimpleGetter() Getter {
	return func(s reflect.Value) []reflect.Value {
		vals := valueSlice(s.Len())
		for i := range vals {
			vals[i] = reflect.Indirect(reflect.Indirect(s.Index(i)))
		}
		return vals
	}
}
653936
func sortStringKeys(m interface{}) []string {
	v := reflect.ValueOf(m)
	t := v.Type()
	if t.Kind() != reflect.Map || t.Key().Kind() != reflect.String {
		panic(fmt.Sprintf(
			"sortStringKeys may be called with a map[string]* only"))
	}

	keys := v.MapKeys()
	sortedKeys := make([]string, 0, len(keys))

	for _, k := range keys {
		key := k.Interface().(string)
		sortedKeys = append(sortedKeys, key)
	}

	sort.Strings(sortedKeys)
	return sortedKeys
}
1288207
func StrsEquals(a, b []string) bool {
	if len(a) != len(b) {
		return false
	}
	sort.Strings(a)
	sort.Strings(b)
	for i, v := range a {
		if v != b[i] {
			return false
		}
	}
	return true
}
530328
func (s *CatCountService) Sort(fields ...string) *CatCountService {
	s.sort = fields
	return s
}
499047
func (m *MockIndex) Slice(arg0 []int, arg1 []byte) [3]int {
	m.ctrl.T.Helper()
	ret := m.ctrl.Call(m, "Slice", arg0, arg1)
	ret0, _ := ret[0].([3]int)
	return ret0
}
546935
func (sl *SkipList) Get(comparators ...common.Comparator) common.Comparators {
	result := make(common.Comparators, 0, len(comparators))

	var n *node
	for _, cmp := range comparators {
		n, _ = sl.search(cmp, nil, nil)
		if n != nil && n.Compare(cmp) == 0 {
			result = append(result, n.entry)
		} else {
			result = append(result, nil)
		}
	}

	return result
}