| 1054 | func (x byIndex) Swap(i, j int) { x[i], x[j] = x[j], x[i] } |
| 1055 | |
| 1056 | func (x byIndex) Less(i, j int) bool { |
| 1057 | for k, xik := range x[i].index { |
| 1058 | if k >= len(x[j].index) { |
| 1059 | return false |
| 1060 | } |
| 1061 | if xik != x[j].index[k] { |
| 1062 | return xik < x[j].index[k] |
| 1063 | } |
| 1064 | } |
| 1065 | return len(x[i].index) < len(x[j].index) |
| 1066 | } |
| 1067 | |
| 1068 | // typeFields returns a list of fields that JSON should recognize for the given type. |
| 1069 | // The algorithm is breadth-first search over the set of structs to include - the top struct |