// SortedString returns a sorted string representation of
// the Map's key value pairs.
517969
func (m Map) SortedString() string {
	buf := bufPool.Get()
	defer bufPool.Put(buf)
	m.sortedWriteBuf(buf)
	return buf.String()
}
907082
func (l Labels) SortedList() []byte {
	var keys []string
	for k := range l {
		keys = append(keys, k)
	}
	sort.Strings(keys)

	result := ""
	for _, k := range keys {
		result += l[k].FormatForKVStore()
	}

	return []byte(result)
}
902615
func (out *DataOutputImpl) WriteStringStringMap(m map[string]string) error {
	if m == nil {
		return out.WriteInt(0)
	}
	err := out.WriteInt(int32(len(m)))
	if err != nil {
		return err
	}
	// enforce key order during serialization
	var keys []string
	for k, _ := range m {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	for _, k := range keys {
		v := m[k]
		// for k, v := range m {
		err = out.WriteString(k)
		if err == nil {
			err = out.WriteString(v)
		}
		if err != nil {
			return err
		}
	}
	return nil
}
198643
func tostring(i interface{}) string {
	var r string
	switch x := i.(type) {
	case string:
		r = x
	case uint64:
		r = strconv.FormatUint(x, 10)
	case int64:
		r = strconv.FormatInt(x, 10)
	case uint:
		r = strconv.FormatUint(uint64(x), 10)
	case int:
		r = strconv.FormatInt(int64(x), 10)
	default:
		log.Panicf("Could not convert %v %t", x, x)
	}
	return r
}
902119
func FormatOrderedMap(keys []string, values []string) string {
	var buf bytes.Buffer
	started := false
	for i, val := range values {
		key := keys[i]
		if started {
			buf.WriteString(MapSeparator)
		}
		buf.WriteString(key)
		buf.WriteString(MapEquals)
		buf.WriteString(val)
		started = true
	}
	return buf.String()
}
285012
func sortedMimes(accept string) (sorted []mime) {
	for _, each := range strings.Split(accept, ",") {
		typeAndQuality := strings.Split(strings.Trim(each, " "), ";")
		if len(typeAndQuality) == 1 {
			sorted = insertMime(sorted, mime{typeAndQuality[0], 1.0})
		} else {
			// take factor
			parts := strings.Split(typeAndQuality[1], "=")
			if len(parts) == 2 {
				f, err := strconv.ParseFloat(parts[1], 64)
				if err != nil {
					traceLogger.Printf("unable to parse quality in %s, %v", each, err)
				} else {
					sorted = insertMime(sorted, mime{typeAndQuality[0], f})
				}
			}
		}
	}
	return
}
567094
func (m *InstanceMap) ListSortedNames() []string {
	var names []string

	for k := range *m {
		names = append(names, k)
	}

	sort.Strings(names)

	return names
}
394859
func (formatter *Formatter) ToString(data interface{}) string {
	if str, ok := data.(string); ok {
		return str
	}

	if byteSlice, ok := data.([]byte); ok {
		return string(byteSlice)
	}

	return fmt.Sprintf("%v", data)
}
509362
func (t TagMap) SortedKeys() []string {
	if len(t) == 0 {
		return nil
	}

	keys := make([]string, 0, len(t))
	for k := range t {
		keys = append(keys, k)
	}
	sort.Strings(keys)
	return keys
}
1126957
func (r *QueryResults) SortedNames() []string {
	names := r.Names()
	sort.Strings(names)
	return names
}
424460
func (d *DecisionTreeNode) getNestedString(level int) string {
	buf := bytes.NewBuffer(nil)
	tmp := bytes.NewBuffer(nil)
	for i := 0; i < level; i++ {
		tmp.WriteString("\t")
	}
	buf.WriteString(tmp.String())
	if d.Children == nil {
		buf.WriteString(fmt.Sprintf("Leaf(%s)", d.Class))
	} else {
		var keys []string
		buf.WriteString(fmt.Sprintf("Rule(%s)", d.SplitRule))
		for k := range d.Children {
			keys = append(keys, k)
		}
		sort.Strings(keys)
		for _, k := range keys {
			buf.WriteString("\n")
			buf.WriteString(tmp.String())
			buf.WriteString("\t")
			buf.WriteString(k)
			buf.WriteString("\n")
			buf.WriteString(d.Children[k].getNestedString(level + 1))
		}
	}
	return buf.String()
}
696679
func ToString(value interface{}) string {
	if v, ok := value.([]string); ok {
		for _, s := range v {
			if s != "" {
				return s
			}
		}
		return ""
	} else if v, ok := value.(string); ok {
		return v
	} else if v, ok := value.([]interface{}); ok {
		for _, s := range v {
			if fmt.Sprint(s) != "" {
				return fmt.Sprint(s)
			}
		}
		return ""
	}
	return fmt.Sprintf("%v", value)
}
878704
func SortedKeysForMap(m yaml.MapSlice) []string {
	keys := make([]string, 0)
	for _, item := range m {
		keys = append(keys, item.Key.(string))
	}
	sort.Strings(keys)
	return keys
}
131223
func (p *SortKeys) AsStringSliceComparator() StringSliceComparator {
	numeric := utils.NewIndex(p.Numeric)
	reverseIndex := utils.NewIndex(p.Reversed)
	comparators := make([]StringComparator, len(p.Keys))
	for i, k := range p.Keys {
		if numeric.Contains(k) {
			comparators[i] = LessNumericStrings
		} else {
			comparators[i] = LessStrings
		}
		if reverseIndex.Contains(k) {
			f := comparators[i]
			comparators[i] = func(l, r string) bool {
				return !f(l, r)
			}
		}
	}
	return AsStringSliceComparator(comparators)
}
959699
func (m Map) GoString() string {
	out := &bytes.Buffer{}
	fmt.Fprintf(out, "%T{", m)
	i := len(m)
	for k, v := range m {
		fmt.Fprintf(out, "%T(%#v): %T(%#v)", k, k, v, v)
		i--
		if i > 0 {
			fmt.Fprint(out, ", ")
		}
	}
	fmt.Fprint(out, "}")
	return out.String()
}
567381
func sortedSliceFromStringIntMap(strMap map[string]uint16) []string {
	strSlice := []string{}
	for k := range strMap {
		strSlice = append(strSlice, k)
	}
	sort.Strings(strSlice)
	return strSlice
}
1266322
func MapToSortedStrings(m map[string]struct{}) []string {
	ss := []string{}
	for k := range m {
		ss = append(ss, k)
	}
	sort.Strings(ss)
	return ss
}