How to get Data in sorted form in spring mongodb Create Query Object and pass your Query Criteria into Query Query query=new Query (criteria); Then Query.sort().on(“sortOnTheBasicOf”, Order . ASCENDING ); Order. ASCENDING for get result in asending order and Order . DESCENDING to get result in Desending order.. sortOnTheBasicOf à Pass the entity name by which you want to sort Pass this query to Your Mangotemplate and Your Class from which You want to get Result mongoTemplate.find(query, YourEntityClassName.class); Then You Got Desired Out put Cheers !!!!!!!!!!!!!!!!!
Loves learning and writing latest Trends.