I have a collection of items that I need to organize into separate lists based on priority levels.
items = [
{'type': 2, 'priority': 1, 'name': 'one'},
{'type': 1, 'priority': 2, 'name': 'two'},
{'type': 1, 'priority': 3, 'name': 'three'},
{'type': 1, 'priority': 4, 'name': 'four'},
{'type': 1, 'priority': 5, 'name': 'five'},
{'type': 2, 'priority': 6, 'name': 'six'},
]
Using ng-repeat
, I want to sort these items by priority and group them by type. Each list should have a maximum sum of 4 for the type
values. The final output should be as follows (sorted by name
)
['one', 'two', 'three', 'four']
['five', 'six']