0

I have a query:

const q = query(collection(db, 'users'), orderBy("highScore", "desc"));

Which returns all the users with all their highscores in descending order. The problem is that there are users who got the same high scores, and now they are ordered I think randomly. So for example, if 3 users get 3000 score it just randomly orders those 3. How can I for example look at another field(a timestamp) and order the last to achieve the 3000 pointsfirst and so on?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Jaydendev
  • 123
  • 2
  • 14

1 Answers1

0

You can use orderBy again in order to sort them, try checking this:

const q = query(collection(db, 'users'), orderBy("highScore", "desc"), orderBy("timestamp", "desc"));

Or, you can do it client-side by sorting them.

You can check this.

Apoorva Chikara
  • 8,277
  • 3
  • 20
  • 35