Nov 5, 2011 at 11:33am UTC
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 Nov 6, 2011 at 11:10pm UTC
Nov 5, 2011 at 12:10pm UTC
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 .
Nov 6, 2011 at 3:34am UTC
Hi,
xSize, ySize and sortRowresult are the first dimension, second dimension and the name of 2d array respectively.
Nov 6, 2011 at 8:22am UTC
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 Nov 6, 2011 at 8:27am UTC