I have a list of objects in my database, and all of them contains field : order
. I want to sort them ascending and descending using the order value from database.
I tried this , but is not sorting like i want, it seems it's ignoring the negative values.
Please help me if you know a way to sort using query. I saw a lot of ways to sort, but i did not find sorting using query that includes negative numbers.
query.with(new Sort(Sort.Direction.ASC, "order"));
query.with(new Sort(Sort.Direction.DESC, "order"));
The field order
has values 0, 2,-5,10, 16,-22
and after the sort expecting: -22,-5, 0, 2, 10, 16
.
Using Spring Data MongoDB version 1.9.2.RELEASE.
question from:
https://stackoverflow.com/questions/65900745/issue-with-sorting-zero-positivie-and-negative-numbers-using-org-springframewor 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…