Is there any efficient way to group dates?

the project requires the implementation of a date grouping function in Wechat"s moments:

as shown in the figure above, it includes grouping by year, grouping content on the same day, and supporting paging. Now the data returned by the background is sorted:

    {
        "2018":{
            "10-1":[{"title":"1","content":"1"}],
            "9-1"[{"title":"2","content":"2"},{"title":"3","content":"3"}]
        },
        "2017":{
            "10-1":[]
        }
    }

then iterate through this object, and as a result, when writing the code, we find that we have to write the nesting of more than three for loops, and then add the data to the list, and the code becomes more complicated instantly. I would like to ask you, how does this function organize the structure of data, or is there any elegant way, such as recursion?

Nov.16,2021

data.reduce ((var b) = > {var [, year,date] = / (\ d +)\-(\ d +\ -\ d +) / .exec (b.createTime); a [year] = a [year] | {}; a [year] [date] = a [year] [date] | | []; a [year] [date] .push (b); return a;}, {})

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3e746-43473.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3e746-43473.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?