Firestore order by time but sort by ID

It will order by document ID (ascending) by default in Swift.

You can use .order(by: '__id__') but the better/documented way is with FieldPath documentID() I don't really know Swift but I assume that it's something like...

.order(by: FirebaseFirestore.FieldPath.documentID())

JavaScript too has an internal variable which simply returns __id__.

.orderBy(firebase.firestore.FieldPath.documentId())

Interestingly enough __name__ also works, but that sorts the whole path, including the collection name (and also the id of course).