Added insertion sorting by coordinate z.