Hello there,
why is this array (SerialNumbers) losing the order of the elements?
I marked my guess in red.
Thanks in advance.
Hello there,
why is this array (SerialNumbers) losing the order of the elements?
I marked my guess in red.
Thanks in advance.
Because you are using .pop()
, which alters the array and changes the meaning of following indices.
In line 55 newArray = serialNumber
This just taking the reference of serialNumber i.e. any changes that is made in newArray will reflect in serialNumber.
What you need to do is to take copy of serialNumber to newArray instead of equating it.
try newArray = serialNumber[:]
or newArray = serialNumber.copy()
I don't exactly know how to take a copy in Jython.
Since this is a native Java array of simple strings, an easy shallow copy would just be list(serialNumbers)
. The slice syntax may work as well, but might be less explicit for a Python newcomer.