I have a list of objects. Here are the object properties (they are a hierarchy) -
School District Id/Name
School Id/Name
Grade Id/Name
Subject Id/Name
Student Id/Name
I have sorted this list by School District, then School, then Grade, and then by Subject. So basically, all items in the list that have the exact same school district, school, grade, and subject will be next to each other in the list.
But how can I split the list into sublists based on this condition? Each sublist would have to be objects with the same school district, school, grade, and subject. I don't want a map or any other data structure - I want a list of lists/sublists.
Thanks.
given that data structures :
here we are:
or, much better, and no need that source list be sorted
I don't know if I got data structure correctly, but in the end what count is the concept:
Taking the term “sub list” literally, if you want a copy-free subList rather than new array lists, here the thing: