function flattenColexicographic( x, ndims, shape, out, stride, offset, clbk, thisArg ) {
	var len;
	var tmp;
	var ord;
	var sh;
	var sx;
	var j;
	var i;

	// Note that, in contrast to lexicographic iteration, we cannot readily define a straightforward recursive definition for colexicographic iteration. Accordingly, we have to perform a workaround in which we first flatten in lexicographic order and then perform an out-of-place transposition to return an array in colexicographic order.

	// Determine how many elements will be in the output array:
	len = numel( shape );

	// For input arrays having an arbitrary number of dimensions, first flatten in lexicographic order:
	tmp = zeros( len );
	recurseLexicographic( x, x, ndims, shape, 0, [], tmp, 1, 0, clbk, thisArg );

	// Define the memory layout:
	ord = 'row-major';

	// Generate a stride array for lexicographic order:
	sx = shape2strides( shape, ord );

	// Reverse the dimensions and strides (i.e., define the shape and strides of the transpose):
	sh = copy( shape );
	grev( ndims, sh, 1 );
	grev( ndims, sx, 1 );

	// Iterate over each element based on the linear **view** index (note: this has negative performance implications due to lack of data locality)...
	for ( i = 0; i < len; i++ ) {
		j = vind2bind( sh, sx, 0, ord, i, MODE );
		out[ offset ] = tmp[ j ];
		offset += stride;
	}
}
Flattens an array in colexicographic order.

@private
@param {Array} x - array to flatten
@param {NonNegativeInteger} ndims - number of dimensions in the input array
@param {NonNegativeIntegerArray} shape - shape of the input array
@param {Collection} out - output array
@param {integer} stride - output array stride
@param {NonNegativeInteger} offset - output array offset
@param {Function} clbk - callback function
@param {*} [thisArg] - callback execution context