I don't think STL has anything that will (significantly) help, other than using vectors to store point data. You'll need to implement your own data structure, similar to the one I described above.

>>would you mind giving an example of how using your structure, I can insert the points, and sort them by each coordinate.

I just made that data structure up, so I don't have any code for manipulating it. However, it should be fairly simple to adapt ordinary linked-list algorithms to the purpose.

For example, if you only consider one element of each node (i.e. node[0]), then the datastructure effectively becomes a singly-linked list, with node[0]->next being your 'next' pointer. So for example, when iterating along each list, you might have:

Code:

Node *xhead,*yhead,*zhead, *xcoord_next, *ycoord_next, *zcoord_next;
xcoord_next = (*xhead)[0].next;
ycoord_next = (*yhead)[1].next;
zcoord_next = (*zhead)[2].next;
xcoord_next = (*xcoord_next)[0].next;
ycoord_next = (*ycoord_next)[1].next;
zcoord_next = (*zcoord_next)[2].next;
etc.

The vector subscript tells you which axis you're dealing with. This is basically representing a point as an ordered triplet, except that we also bundled in a pointer, which allows us to link the individual coordinates into lists.

So you can see, once you insert a point at an arbitrary position in the structure, and re-form the links along each coordinate axis, it's a simple matter to run the structure through a slightly modified list-sorting algorithm N times, changing the vector subscript each time. The result: N sorted lists, using the same 'point' structures.