I have items on my list and the items have a field, which shows the creation date of the item.
and I need to group them based on a “squeeze”, which the user gives. The options are Day
name__, Week
name__, Month
And Year
name__.
If the user selects compression day
name__, I need to group my articles in such a way that the elements, which are created on the same day, will be filled. In my example above, only items 1 and 2 are created on the same day. The others are also groups but they will have only one object because in their day only one object is created.
{{item1, item2}, {item3}, {item4}, {item5}, {item6}, {item7}}
If the user selects week
name__:
{{item1, item2, item3, item4}, {item5}, {item6}, {item7}}
If the user selects month
name__:
{{item1, item2, item3, item4, item5}, {item6}, {item7}}
If the user selects year
name__:
{{item1, item2, item3, item4, item5, item6}, {item7}}
After the groups are created, the date of the articles is not important. I mean the key can be anything as long as groups are created.
In case of using Map
name__, I thought like the keys as follows:
day
= day of the yearweek
= week of the yearmonth
= month of the yearyear
= year
What would be the best solution to this problem? I couldn’t even start it and can’t think of a solution other than iteration.