Say I have a below list
full_list
ID NAME
1 Apple
1 Banana
2 Carrot
1 Mango
2 Spinach
3 BMW
3 Opal
With this single list, I want to create a grouped list based on column ID
like below
fruits_list veggies_list cars_list
ID NAME ID NAME ID NAME
1 Apple 2 Carrot 3 BMW
1 Banana 2 Spinach 3 Opal
1 Mango
I was trying to do it with Arraylist<ArrayList<CustomObject>>
. But it is adding more complexity to the code. Am I doing it wrong? Is there any cleaner way to do this?
PS: Data incoming is not fixed. I cannot define lists explicitly with conditions (i.e. if(id==1), if(id==2) etc). This shall be done dynamically based on incoming data.