mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-18 22:23:07 -03:00
cli: sort the results
Adds `FileCount` and `FileCountList` types for storing language file and their count which can be sorted based on the value of count. Signed-off-by: Sunny <me@darkowlzz.space>
This commit is contained in:
14
utils.go
14
utils.go
@ -89,3 +89,17 @@ func IsBinary(data []byte) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// FileCount type stores language name and count of files belonging to the
|
||||
// language.
|
||||
type FileCount struct {
|
||||
Name string
|
||||
Count int
|
||||
}
|
||||
|
||||
// FileCountList type is a list of FileCounts.
|
||||
type FileCountList []FileCount
|
||||
|
||||
func (fcl FileCountList) Len() int { return len(fcl) }
|
||||
func (fcl FileCountList) Less(i, j int) bool { return fcl[i].Count < fcl[j].Count }
|
||||
func (fcl FileCountList) Swap(i, j int) { fcl[i], fcl[j] = fcl[j], fcl[i] }
|
||||
|
Reference in New Issue
Block a user