I canβt understand why he is not returning in the reverse order.
But you can create an array in the helper method of the template and return the return value of the array using the functions array.sort() or array.reverse() .
For example: let's say that the Answers collection looks like this:
Answers({ansNo: 1, ansBody: "body1"}, {ansNo: 2, ansBody: "body2"}, {ansNo: 3, ansBody: "body3"});
And the returned array:
var AnswersArr = new Array();
then in your template helper: β
var tempCollection = Answers.find({}); tempCollection.forEach(function(data){ var obj = {ansNo: data.asnNo, ansBody: data.ansBody}; AnswersArr.push(abj); }); AnswersArr.sort(function(a, b){return b.ansNo - a.ansNo;});
sohel khalifa
source share