2

I have i think really stupid question, but can I assign one line in the two dimensional array to be "stuck" with the other? What I mean is that I want to sort my array by one line but i want the other line to change as well.

I have an array in which one line is ID of the Container and in the other is the weight of the container. It looks somewhat like this:

 [1,2,3,4,5]

  
[3.2,2.3,6.5,9.3,5.6] 

And when I sort the second line (weight) the upper doesn't change, and I want it to change as well because it's the id of the container and the weight is also connected this container.

Spectric
  • 30,714
  • 6
  • 20
  • 43
  • It would be better to create a class that contains one full row. In this case it would contain an int and a double. Otherwise you have to manually keep the arrays synchronized, which almost always leads to difficult to find bugs. – NomadMaker Feb 04 '21 at 05:34

0 Answers0