I have an array containing duplicate elements. What I need is to get those duplicate elements to new sub-arrays.
For example:
I have the main array, array = [ a, b, c, a, d, c, c, b, a ]
what I need is to get this array divide into new sub-arrays dynamically like below:
subArray1 = [ a,a,a]
subArray2 = [b,b]
subArray3 = [c,c,c]
subArray4 = [d]
Thanks.