I need to store an array of Int array for ordered duplicates (which are in a Array).
Example:
mainArray = [7, 7, 3, 2, 2, 2, 1,
This is a programming logic problem problem. Your current code is totally wrong.
Here's one way you could solve it:
Start out by sorting your starting array. call that inputArray.
Create new, empty output "outerArray" and "innerArray" variables. Then loop through the entries in inputArray, testing for changes in value. If the value is the same as the last value, add that value to "innerArray". If the value has changed, save the previous innerArray to the outerArray and create a new, empty array and save it to innerArray.