github.com/getgauge/gauge@v1.6.9/order/sort.go (about) 1 /*---------------------------------------------------------------- 2 * Copyright (c) ThoughtWorks, Inc. 3 * Licensed under the Apache License, Version 2.0 4 * See LICENSE in the project root for license information. 5 *----------------------------------------------------------------*/ 6 7 package order 8 9 import ( 10 "sort" 11 12 "github.com/getgauge/gauge/gauge" 13 ) 14 15 var Sorted bool 16 17 type byFileName []*gauge.Specification 18 19 func (s byFileName) Len() int { 20 return len(s) 21 } 22 23 func (s byFileName) Swap(i, j int) { 24 s[i], s[j] = s[j], s[i] 25 } 26 27 func (s byFileName) Less(i, j int) bool { 28 return s[i].FileName < s[j].FileName 29 } 30 31 func Sort(specs []*gauge.Specification) []*gauge.Specification { 32 if Sorted { 33 sort.Sort(byFileName(specs)) 34 } 35 return specs 36 }