In reply to sharatk:
It might help to show some examples of array values you’re looking to see and explain in words, nut SystemVerilog syntax the requirements that the arrays need to meet.
Also, pipe[i].sum with (item.index < j)
just returns j-1; a count of items whose index is less than j. You are probably looking for pipe[i].sum with ((item.index < j) ? item : 0 )