1. ## Multi dimensional array

In the book im studing it shows you how to bubble sort a single subscripted array. I see nothing on doing that with a double subscripted array. So I have just been messing with it to see and I cant get it sort the array. Here's the code.
Code:
void bubbleSort(int c[][5])
{
int hold;
for ( int i = 0; i < 3; i++ )

for ( int j = 0; j < 5 - 1; j++ )

if( c[i][j] > c[i][ j + 1 ] ) {
hold = c[i][j];
c[i][j] = c[i][ j + 1 ];
c[i][ j + 1 ] = hold;
}
for( int k = 0; k < 3; k++ ) {

for( int l = 0; l < 5; l++ )

cout << c[k][l] << ' ' ;
}
}
Im not at the level of vectors and such. I run this on the array and it moves some of them but it doesnt put them in the proper order.

2. How you sort a 2D array depends on what you expect to see when you've finished

4 5 6
1 2 3
7 8 9

Sorted by [x][0] gets you this for example

1 2 3
4 5 6
7 8 9

3. ## Hi

Basicly I just want to sort a 3 x 5 array in ascending order. I have used the algorithym posted for single subscripted arrays and it works fine.But I cant get it to work for double subscripted arrays.
the code posted above is for the array im using.

4. Here's one way. Use a double for-loop like:
Code:
for (int i=0; i<3*5-1; i++)
{
for (int j=i; j<3*5; j++)
{
}
}
Then you can calculate row and column of your array by using division(/) and modulus(%).

5. The problem that Salem is getting at is that 'ascending order' is not well defined for a multi-dimensional array. You could set them up as in Salem's example or arrange them column-wise, or a host of other (probably somewhat absurd) variations.