Implement z-order

I implemented simple z-order handling with index.