Check out example codes for "order documents in firestore". It will help you in understanding the concepts better.

Code Example 1

// Create Data
const timestamp = firebase.firestore.FieldValue.serverTimestamp;

db.collection('things').add({ ...myData, createdAt: timestamp() })


// Query
db.collection('things').orderBy('createdAt').startAfter(today)

Learn ReactJs, React Native from akashmittal.com