mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 08:42:51 +00:00
Consider sort direction when sorting the Article array for the timeline.
This commit is contained in:
1 parent
6e63ce5968
commit
28c4ea82e5
1 file changed
+9
-10
@@ -64,9 +64,16 @@ extension Array where Element == Article {
|
||||
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 {
|
||||
@@ -95,12 +102,4 @@ private extension Array where Element == Article {
|
||||
|
||||
return rowForArticleID(article.articleID)
|
||||
}
|
||||
|
||||
// MARK: Sorting
|
||||
|
||||
func articleComparator(_ article1: Article, article2: Article) -> Bool {
|
||||
|
||||
return article1.logicalDatePublished > article2.logicalDatePublished
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user