aboutsummaryrefslogtreecommitdiff
path: root/sx-question.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2015-01-16 00:54:32 -0500
committerSean Allred <code@seanallred.com>2015-01-16 00:54:32 -0500
commitfe140f7891257890687ec6e3243d66f1aa95fc65 (patch)
treecee86917c73725c7f8d3a33e0f4cf85ae76a1efb /sx-question.el
parent22f86c35499f994f0eb7532b8eb27b0d990d889d (diff)
parent6c4e7c6b95e8bd7d83e5d0f868d9fb3a70c7a974 (diff)
Merge pull request #228 from vermiculus/vermiculus/sort-answers
Customizable sorting; Fix #226. Generalization of #225.
Diffstat (limited to 'sx-question.el')
-rw-r--r--sx-question.el15
1 files changed, 15 insertions, 0 deletions
diff --git a/sx-question.el b/sx-question.el
index 1adbc24..1e3a02c 100644
--- a/sx-question.el
+++ b/sx-question.el
@@ -187,6 +187,21 @@ If no cache exists for it, initialize one with SITE."
"Formats TAG for display."
(concat "[" tag "]"))
+
+;;; Question Mode Answer-Sorting Functions
+
+(sx--create-comparator sx-answer-higher-score-p
+ "Return t if answer A has a higher score than answer B."
+ #'> (lambda (x) (cdr (assq 'score x))))
+
+(sx--create-comparator sx-answer-newer-p
+ "Return t if answer A was posted later than answer B."
+ #'> (lambda (x) (cdr (assq 'creation_date x))))
+
+(sx--create-comparator sx-answer-more-active-p
+ "Return t if answer A was updated after answer B."
+ #'> (lambda (x) (cdr (assq 'last_activity_date x))))
+
(provide 'sx-question)
;;; sx-question.el ends here