I'm new to this and I need to sort my data. I have defects with an array, called priorities, that has some names in it. Now I want to sort them in descending order based on the length of the array. I'm struggling and can't seem to find how to do this. This is my code:
@GetMapping("/defects/sort/priority")
public List<Defect> defects2() { return defectRepository.sortAllDefectByPriority(); }
also:
@Query("{ $sort: { $size: '$priorities' }: -1 }")
public List<Defect> sortAllDefectByPriority();
Can anyone help me? EDIT: I only know how to use @Query annotations