Sort the rows of 2d array

I am going to sort the rows of 2d array.

1
2
3
4
5
6
7
8
9
10
 
 string **sortRowresult;
    sortRowresult = new string*[ySize];
    for (int i = 0; i < ySize; ++i)
        *(sortRowresult + i) = new string[xSize];
    
for (int i = 0; i < ySize; i++)
    {
        std::sort(sortRowArray + xSize, (sortRowArray + (xSize * i)));
    }


But it seems that there is a problem!
Last edited on
Hi ,
There seems to be three unkown parameters to me , xSize , ySize and array . SortRowArray is also an unkown parameter . Can you elobrate on this .
Hi,
xSize, ySize and sortRowresult are the first dimension, second dimension and the name of 2d array respectively.
http://www.cplusplus.com/reference/algorithm/sort/

why cant we do ..
std::sort(sortRowArray + xSize, array + xSize );

also we can do ....

bool myfunction (int i,int j) { return (i<j); }

and

std::sort(sortRowArray + xSize, array + xSize , myfunction);


Last edited on
Topic archived. No new replies allowed.