I am importing csv data to firestore by parsing it. The csv is making documents randomly without following the date's chronological order e.g 2019's data first and 2022 or latest data at last. I want to show the data chronological wise on the app side or even if possible on the javascript side of firebase while parsing I'm ready to make changes.
Format is dd-mm-yyyy
I've tried orderBy
but it didn't worked.
Note that there's Date
field as well in my every document and I can't use Timestamp
cause data is coming from csv.
I'm attaching image of my app and firestore document id and collection to get an better idea of what I want to achieve.
CodePudding user response:
Document IDs are strings, so they use lexicographical sort order. If you want them to also be sorted chronologically, you should use a date format that fits those needs. For example ISO-8601: 2022-09-15
. In this format, ordering by document ID will put the documents in the order of the date.