2d array

Can I control only the row in a 2d array? I am trying to use flat sorting in a 2d array, where I should sort the array descendingly according to one particular column
For instance,

A B 12
A L 13
A p 14

it should be

A P 14
A L 13
A B 12

Any help?
Last edited on
You can,element[i][j] is a lement of Matrix i*j,i-rows,j-columns.
If you want to sort only columns than j is fixed and you only iterate i with some loop.
Thanks for answering
I did something to sort according to column number five but it doesn't work
May you please tell me what's wrong?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
do
        {
            flag = false;
            for (int c = 0; c < count-1; c++)
            if (s[c+1][5] > s[c][5])
            {
                for (int j = 0; j<6;j++)
                {
                t[c+1][j] = s[c][j];
                s[c][j] = s[c+1][j];
                s[c+1][j] = t[c][j];
                }
                flag = true;
            }
        } while (flag);
Last edited on
double post. I gave an approach in the other one. Please don't do that.
I do not know that are you trying to do in this code.You can tell your whole problem what do you need to do.
Topic archived. No new replies allowed.