mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-29 19:11:24 +01:00
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user