Drawing order of Objects in an Arraylist

the code definetely works. What I am wondering now if its possible to walk through that zMax loop the other way around? because right now when two of the same objects are above each other it deletes the one that has been placed first wich is the bottom one.

I also used your example to implement a drag and drop functionality. And the same problem occurs, because when I drag one Object over another with the same Z value wich has been created before the one im dragging it switches over that one and drags that