I have a query that returns a single document but have a map field. I would like to sort the map elements, is this possible?
The data is something like this:
Calendars:
{
"_id" : "1f5c0468-3249-4eee-ae65-79fc134f37c7",
"countryId" : "60a562ba-43d1-48b3-bd07-7aebbb2c0123",
"name" : "Bangladesh Holiday 2019",
"year" : 2019,
"holidays" : {
"2019-02-21" : "Language Martyrs' Day",
"2019-03-17" : "Sheikh Mujibur Rahman's birthday",
"2019-03-26" : "Independence Day",
"2019-04-14" : "Bengali New Year",
"2019-04-21" : "Shab e-Barat",
"2019-05-01" : "May Day",
"2019-05-19" : "Buddha Purnima",
"2019-05-31" : "Jumatul Bidah",
"2019-06-01" : "Night of Destiny",
"2019-06-02" : "Night of Destiny",
"2019-06-03" : "Compensate leave for Night of Destiny",
"2019-06-04" : "Eid al-Fitr",
"2019-06-05" : "Eid ul-Fitr",
"2019-06-06" : "Eid ul-Ftr Holiday",
"2019-08-09" : "Compensate leave for Eid ul-Adha",
"2019-08-11" : "Eid ul-Adha Day 1",
"2019-08-12" : "Eid ul-Adha Day 2",
"2019-08-13" : "Eid ul-Adha Day 3",
"2019-08-15" : "National Mourning Day",
"2019-08-23" : "Janmashtami",
"2019-09-10" : "Ashura",
"2019-10-08" : "Durga Puja",
"2019-11-10" : "Eid e-Milad-un Nabi",
"2019-12-16" : "Victory Day",
"2019-12-25" : "Christmas Day"
}
}
The simple query to get a particular document is like this:
db.getCollection('calendars').find({ "_id" : "1f5c0468-3249-4eee-ae65-79fc134f37c7" })
Now, is it possible to sort the map of holidays by date?