Add additional sort criteria for when published date is equal. Issue #644

This commit is contained in:
Maurice Parker 2019-06-13 15:51:28 -05:00
parent 6527ac852c
commit 46bc867241
1 changed files with 3 additions and 0 deletions

View File

@ -53,6 +53,9 @@ extension Array where Element == Article {
func sortedByDate(_ sortDirection: ComparisonResult) -> ArticleArray {
let articles = sorted { (article1, article2) -> Bool in
if article1.logicalDatePublished == article2.logicalDatePublished {
return article1.articleID < article2.articleID
}
if sortDirection == .orderedDescending {
return article1.logicalDatePublished > article2.logicalDatePublished
}