From 249d3dd906ab5b3030b1a25a49ea66205e6a64bb Mon Sep 17 00:00:00 2001 From: kumar Date: Mon, 25 Jul 2016 09:29:51 -0400 Subject: returns solutions sorted by vote count --- node_simple.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'node_simple.js') diff --git a/node_simple.js b/node_simple.js index 165eb22..b2c22ea 100644 --- a/node_simple.js +++ b/node_simple.js @@ -760,6 +760,7 @@ exports.add_comment = function (sol_id, fields, serverCallback) { /** * This function will get all the solution for a given exam_id and q_num + * sorted by highest to lowest votes. * * @param {string} exam_id: exam_id for which the info is required. * @param {int} q_num: the question number for which solutions are required. @@ -776,7 +777,7 @@ exports.get_all_solutions = function (exam_id, q_num, callback) { exam_id: exam_id, q_id: q_num } - ).toArray( function (err, docs) { + ).sort({ votes: -1}).toArray( function (err, docs) { if (err) throw err; else { callback(docs); -- cgit v1.2.3