@@ -47,9 +47,13 @@ func RawValuesFrom(values ...string) RawValues {
4747}
4848
4949func (r RawValues ) Unique () RawValues {
50- uniqueRawValues := make (map [string ]RawValue )
50+ type key struct {
51+ Value string
52+ Uid string
53+ }
54+ uniqueRawValues := make (map [key ]RawValue )
5155 for _ , value := range r {
52- uniqueRawValues [value .Value ] = value
56+ uniqueRawValues [key { value .Value , value . Uid } ] = value
5357 }
5458
5559 rawValues := make ([]RawValue , 0 , len (uniqueRawValues ))
@@ -150,6 +154,17 @@ func (a ByValue) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
150154// ByDisplay alias to filter by display.
151155type ByDisplay []RawValue
152156
153- func (a ByDisplay ) Len () int { return len (a ) }
154- func (a ByDisplay ) Less (i , j int ) bool { return a [i ].Display < a [j ].Display }
155- func (a ByDisplay ) Swap (i , j int ) { a [i ], a [j ] = a [j ], a [i ] }
157+ func (a ByDisplay ) Len () int { return len (a ) }
158+ func (a ByDisplay ) Less (i , j int ) bool {
159+ if a [i ].Display == a [j ].Display {
160+ return ByUid (a ).Less (i , j ) // ensure consistency in export
161+ }
162+ return a [i ].Display < a [j ].Display
163+ }
164+ func (a ByDisplay ) Swap (i , j int ) { a [i ], a [j ] = a [j ], a [i ] }
165+
166+ type ByUid []RawValue
167+
168+ func (a ByUid ) Len () int { return len (a ) }
169+ func (a ByUid ) Less (i , j int ) bool { return a [i ].Uid < a [j ].Uid }
170+ func (a ByUid ) Swap (i , j int ) { a [i ], a [j ] = a [j ], a [i ] }
0 commit comments