Consider sort direction when sorting the Article array for the timeline.
This commit is contained in:
parent
6e63ce5968
commit
28c4ea82e5
|
@ -64,9 +64,16 @@ extension Array where Element == Article {
|
||||||
return indexes
|
return indexes
|
||||||
}
|
}
|
||||||
|
|
||||||
func sortedByDate() -> ArticleArray {
|
func sortedByDate(_ sortDirection: ComparisonResult) -> ArticleArray {
|
||||||
|
|
||||||
return sorted(by: articleComparator)
|
let articles = sorted { (article1, article2) -> Bool in
|
||||||
|
if sortDirection == .orderedDescending {
|
||||||
|
return article1.logicalDatePublished > article2.logicalDatePublished
|
||||||
|
}
|
||||||
|
return article1.logicalDatePublished < article2.logicalDatePublished
|
||||||
|
}
|
||||||
|
|
||||||
|
return articles
|
||||||
}
|
}
|
||||||
|
|
||||||
func canMarkAllAsRead() -> Bool {
|
func canMarkAllAsRead() -> Bool {
|
||||||
|
@ -95,12 +102,4 @@ private extension Array where Element == Article {
|
||||||
|
|
||||||
return rowForArticleID(article.articleID)
|
return rowForArticleID(article.articleID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Sorting
|
|
||||||
|
|
||||||
func articleComparator(_ article1: Article, article2: Article) -> Bool {
|
|
||||||
|
|
||||||
return article1.logicalDatePublished > article2.logicalDatePublished
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue