How can I group points by their Z value and draw a nurbs curve between them?

Post code!