Fast Z Sorting any tips?

My game has an overview of a street with buildings etc…

The problem is most of my game objects need to be sorted on depth so that they appear to be in a 3d scene.

When a lot of objects come on screen the game tends to get a little choppy, even with frame rate independant game logic which handles most choppiness very well.

The problem area I’ve isloated it to is the array.sort function.

The actual swapDepths for all objects which need sorting is very quick - but the array sorting is very slow - taking more than 30 times as long sometimes to sort the objects.

Are there any sorting algorithms which will work on object types in an array which will give me quicker results as I’m using a comparison function with the default array sort at the moment?

Can I use bucket sorting/quicksort etc on an object array or can this only be used on numerical arrays?