pass in the x,y,z sizes on the interface and generally you roll down and in

Code:
void SortVectors(  vector [x,y,z],   unsigned short xsize, unsigned short ysize, unsigned short zsize){
unsigned short x, y, z;
 
for (z = 0; z < zsize; z++) {
    for  (y = 0; y < ysize; y++) {
        for (x = 0; x < xsize; x++) {
             // do whatever with  vector[x,y,z] 
       }
    }
};