aboutsummaryrefslogtreecommitdiff
path: root/sx-question-print.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2015-01-14 08:41:38 -0500
committerSean Allred <code@seanallred.com>2015-01-14 08:41:38 -0500
commit766d008e12d7164053bda6d56f336af442109232 (patch)
tree1be5e141086216b9e4cf9e590c5fcc28068ad989 /sx-question-print.el
parent128ec0191ea586f94dfe9b905b29205f6285d50a (diff)
Sort answers by score
Diffstat (limited to 'sx-question-print.el')
-rw-r--r--sx-question-print.el7
1 files changed, 6 insertions, 1 deletions
diff --git a/sx-question-print.el b/sx-question-print.el
index e120752..737844a 100644
--- a/sx-question-print.el
+++ b/sx-question-print.el
@@ -179,7 +179,12 @@ QUESTION must be a data structure returned by `json-read'."
;; Print everything
(sx-question-mode--print-section question)
(sx-assoc-let question
- (mapc #'sx-question-mode--print-section .answers))
+ (mapc #'sx-question-mode--print-section
+ (cl-sort .answers
+ ;; Highest-voted first. @TODO: custom sorting
+ (lambda (a b)
+ (> (cdr (assoc 'score a))
+ (cdr (assoc 'score b)))))))
(insert "\n\n ")
(insert-text-button "Write an Answer" :type 'sx-button-answer)
;; Go up