Query MongoDB for ordered distinct values
问题 I am using Morphia Java driver for querying a MongoDB that contains a collection of the following form: MyCollection { TypeA TypeB } I want to retrieve all distinct values of TypeB which I do using the following code: DBCollection myCol = getDatastore().getCollection(MyCollection.class); List typeBs = myCol.distinct("TypeB"); Above code works as expected, but list of distinct values is of course not sorted. I have experimented with the following code: DBCollection myCol = getDatastore()