File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed
Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change 11package i3parse
22
3+ import "sort"
4+
35func compareSlices (a []string , b []string ) bool {
46 if len (a ) != len (b ) {
57 return false
@@ -14,6 +16,14 @@ func compareSlices(a []string, b []string) bool {
1416 return true
1517}
1618
19+ type sortByNumBindings []ModifierGroup
20+
21+ func (a sortByNumBindings ) Len () int { return len (a ) }
22+ func (a sortByNumBindings ) Swap (i , j int ) { a [i ], a [j ] = a [j ], a [i ] }
23+ func (a sortByNumBindings ) Less (i , j int ) bool {
24+ return len (a [i ].Bindings ) > len (a [j ].Bindings )
25+ }
26+
1727//GetModifierGroups groups bindings that have the same modifiers
1828func GetModifierGroups (bindings []Binding ) []ModifierGroup {
1929 var groups []ModifierGroup
@@ -33,6 +43,7 @@ func GetModifierGroups(bindings []Binding) []ModifierGroup {
3343 })
3444 }
3545 }
46+ sort .Sort (sortByNumBindings (groups ))
3647
3748 return groups
3849}
You can’t perform that action at this time.
0 commit comments