method required to implement sort.Interface
(i, j int)
| 88 | |
| 89 | // method required to implement sort.Interface |
| 90 | func (s sortableByKey) Less(i, j int) bool { |
| 91 | dataI := getFieldAsString(s.data[i], s.key) |
| 92 | dataJ := getFieldAsString(s.data[j], s.key) |
| 93 | |
| 94 | if intI, err := strconv.ParseInt(dataI, 10, 64); err == nil { |
| 95 | if intJ, err := strconv.ParseInt(dataJ, 10, 64); err == nil { |
| 96 | // If both are integers, compare as integers |
| 97 | return intI < intJ |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | return dataI < dataJ |
| 102 | } |
| 103 | |
| 104 | // Generalized SortBy function |
| 105 | func generalizedSortBy(funcName string, entries interface{}, s sortable, reverse bool) (sorted []interface{}, err error) { |
nothing calls this directly
no test coverage detected