Skip to content

Commit

Permalink
fix: sort by language name if count is same
Browse files Browse the repository at this point in the history
  • Loading branch information
mahyarmirrashed committed Dec 21, 2024
1 parent 92ccc67 commit 61f2d4f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/stats/languages.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,14 @@ func GetLanguageData(
return "no languages found", nil
}

// Sort by count descending
// Sort aggregated languages
sort.Slice(aggregatedLanguages, func(i, j int) bool {
return aggregatedLanguages[i].Count > aggregatedLanguages[j].Count
if aggregatedLanguages[i].Count != aggregatedLanguages[j].Count {
// Sort by count descending if counts are not equal
return aggregatedLanguages[i].Count > aggregatedLanguages[j].Count
}
// Sort by name ascending, otherwise
return aggregatedLanguages[i].Name < aggregatedLanguages[j].Name
})

// Build output
Expand Down

0 comments on commit 61f2d4f

Please sign in to comment.