Spring MongoDB query sorting
sWhen you've written a custom query in your repository then you can perform sorting during invocation. Like,
Repository
@Query("{ 'id' : ?0}")List<Student> findStudent(String id, Sort sort);
During invocation
Sort sort = new Sort(Sort.Direction.ASC, "date")List<Student> students = studentRepo.findStudent(1, sort);
I hope this helps! :)