Sort Array Inventory by Amount

You can just do a reverse loop removing index with 0 quantity and then if you want the lenght of the array to stay the same just resize it as before.

Remove Index will delete the array item and push the remaining like:

index0 Item1

index1 Item2

index2 Item3

index3 Item4

Remove Index(1)

index0 Item1

index1 Item3

index2 Item4