   Drawing Sprites in different orders
  I have some sprite classes with which I have sprites moving over and on top of each other.I can test whether a sprite goes on top or below another sprite.The problem is:How do I store this data which tells the program which order to draw the sprites?I was thinking about an array in which you load the sprites in and you re-order it when you find a sprite goes on top of another sprite. Then the program simply draws it from the first element until it reaches the end. The problem with this is that it can get pretty hefty (especially when you need to insert a sprite somewhere in the array- then everything above it gets shifted upwards).My second thought would be to have a variable in the classes storing info on the sprites position to be drawn, but then this would mean that I would have to loop round every single sprite every time i want to draw the next sprite (testing which sprite is next).Any other ideas or help? 
  Look into linked lists. ;  Trees work perfectly. Absolutely great. ;  yes, i didnt think of linked lists. Trees? How would that work when you have to follow on directly from something else? Do you mean have a sorta hierarchy where objects point to which things are below them + have to be drawn? ;  Are trees or linked lists going to be any faster than a simple quicksort on an array or vector (based upon your rendering order variable)? ;  I''m not sure if a binary tree is faster than quicksorting an array or vector. . .  I''ve never actually done the comparison -- but either would certainly be faster than just a linked list. ;  Inserting something into a linked list is faster than a sort. ;  Personally, I think a deque would be a better structure for this purpose.  It is faster to traverse than a deque than a linked list, and inserting something into it is faster than a vector or array.  If you are inserted at the beginning or end of the deque, it is as fast as a vector.  What kind of game are you designing?  Is it something where high frame rates are vital, like a FPS, or is it something that you can afford a slight frame rate hit, like a turn-based strategy game? ;  yeah. using trees, you sort as you go. using dynamically sized arrays (i.e. vectors), its such a hassle. i just came back from the pits of hell trying to make my code elegant and memory-leak-free while trying to implement both dynamically sized arrays AND vectors, and THEN doing a quicksort at rendering, its a nightmare. For me at least. And then I discovered the beauty of trees. Much, much more cleaner and faster. ;  its a 2d rpg- not exactly memory intensive. The problem is if I store in a dynamic array inserting an object in is very difficult (as I then have to shift everything up). Linked lists sounds good.With linked lists, because we''re linking to different classes I cannot store the address so I have to use an ID number (which is OK because all the sprites are stores in an array).I am interested in trees though, can someone tell me what they are? 