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

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -