mongodb - Sorting in distinct data -
on calling db.distinct() method return data in ascending order sorted. way can data sorted in descending order?
the distinct command returns javascript array, can sort , reverse it:
var array = db.coll.distinct("{field_name}") array.sort() array.reverse()
if using java driver, can such as:
list list = coll.distinct("{field_name}"); collections.sort(list); collections.reverse(list);
Comments
Post a Comment