Reputation: 1400
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?
Upvotes: 9
Views: 2971
Reputation: 4391
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.
Upvotes: 16