Should containers be in charge of ordering, or the items themselves?
Approach 1:
class Item
{
string GroupId;
int GroupOrder;
}
var items = [...];
var groups = items.orderBy(x => x.GroupOrder).groupBy(x => x.GroupId);
This approach seems tedious if I want to reorder items, since I might have to update many items GroupOrder when moving one.
Approach 2:
class Group
{
string Id;
List<Item> Items;
}
var groups = new List<Groups>
{
new Group { Id = "group.one", Items = ... },
new Group { Id = "group.two", Items = ... },
...
}
This approach seems easier to move items around, but involves manual entry into the Lists themselves
Should containers be in charge of ordering, or the items themselves?
Approach 1:
class Item
{
string GroupId;
int GroupOrder;
}
var items = [...];
var groups = items.orderBy(x => x.GroupOrder).groupBy(x => x.GroupId);
This approach seems tedious if I want to reorder items, since I might have to update many items GroupOrder when moving one.
Approach 2:
class Group
{
string Id;
List<Item> Items;
}
var groups = new List<Groups>
{
new Group { Id = "group.one", Items = ... },
new Group { Id = "group.two", Items = ... },
...
}
This approach seems easier to move items around, but involves manual entry into the Lists themselves