diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2017-12-03 20:39:01 -0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-04 12:39:01 +0800 |
commit | c0a7899416af728634b2dc52a27b31255285ae7e (patch) | |
tree | 78c4b391ad9fb6b226737f66ab63ab03528c76ab /models | |
parent | 3c1b1ca78e93fb464a5bb64aae9d845bc9f0b9c0 (diff) | |
download | gitea-c0a7899416af728634b2dc52a27b31255285ae7e.tar.gz gitea-c0a7899416af728634b2dc52a27b31255285ae7e.zip |
Sort repos in issues dashboard sidebar (#3072)
* Sort repos in issues dashboard sidebar
* Sort repos by name
Diffstat (limited to 'models')
-rw-r--r-- | models/repo_list.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/models/repo_list.go b/models/repo_list.go index 883e3b98d5..d13266f208 100644 --- a/models/repo_list.go +++ b/models/repo_list.go @@ -16,6 +16,18 @@ import ( // RepositoryList contains a list of repositories type RepositoryList []*Repository +func (repos RepositoryList) Len() int { + return len(repos) +} + +func (repos RepositoryList) Less(i, j int) bool { + return repos[i].FullName() < repos[j].FullName() +} + +func (repos RepositoryList) Swap(i, j int) { + repos[i], repos[j] = repos[j], repos[i] +} + // RepositoryListOfMap make list from values of map func RepositoryListOfMap(repoMap map[int64]*Repository) RepositoryList { return RepositoryList(valuesRepository(repoMap)) |