I have the following Result Class in Parse:
score <Number> | miliseconds <Number>
50 | 500
100 | 10000
100 | 20000
50 | 1000
50 | 2000
100 | 99999
I'm trying to sort descending by score first and then ascending by miliseconds
First try:
var query = new Parse.Query('Result')
query.descending('score')
query.ascending('time')
return query.find()
And I get this:
score <Number> | miliseconds <Number>
50 | 500
50 | 1000
50 | 2000
100 | 10000
100 | 20000
100 | 99999
Second try:
var query = new Parse.Query('Result')
query.ascending('time')
query.descending('score')
return query.find()
Result:
score <Number> | miliseconds <Number>
100 | 99999
100 | 10000
100 | 20000
50 | 500
50 | 1000
50 | 2000
What am I expecting?
I'm expecting to have a result like this:
score <Number> | miliseconds <Number>
100 | 10000
100 | 20000
100 | 99999
50 | 500
50 | 1000
50 | 2000
Am I doing something wrong here?
Try this way:
var query = new Parse.Query('Result')
query.descending('score')
query.addAscending('time')
return query.find()
The thing is to add another sorting condition, not overriding pervious one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With