File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 99 "strconv"
1010 "strings"
1111 "sync"
12+ "sort"
1213)
1314
1415type Tag struct {
@@ -56,6 +57,11 @@ func getInstances(config Config) (clouds CloudInstances) {
5657 return
5758}
5859
60+ type SortByTagValue []StrMap
61+ func (a SortByTagValue ) Len () int { return len (a ) }
62+ func (a SortByTagValue ) Swap (i , j int ) { a [i ], a [j ] = a [j ], a [i ] }
63+ func (a SortByTagValue ) Less (i , j int ) bool { return a [i ]["tag_value" ] < a [j ]["tag_value" ]}
64+
5965func getMatchedInstances (clouds CloudInstances , filter string ) (matched []StrMap ) {
6066 // Fuzzy matching, like SublimeText
6167 filter = strings .Join (strings .Split (filter , "" ), ".*?" )
@@ -78,8 +84,10 @@ func getMatchedInstances(clouds CloudInstances, filter string) (matched []StrMap
7884 }
7985 }
8086 }
87+
88+ sort .Sort (SortByTagValue (matched ))
8189
82- return
90+ return
8391}
8492
8593func formatMatchedInstance (inst StrMap ) string {
You can’t perform that action at this time.
0 commit comments