Hi, I have code, where I need to sort two dimensional array. I know I can use qsort(), but I would like to try std::sort to do this. Is it even possible to sort 2D array using std::sort?
Here is the code:
1 2 3 4 5 6 7 8
int **array;
int n = 100;
array = (int **)malloc(size * sizeof(int *));
for(int i = 0; i < n; i++)
{
array[i] = (int *)malloc((3) * sizeof(int));
}
std::sort(array, array+n,cmp_int);
When I compile and run the code, SEGMENTATION FAULT occures at comparison of two values, becouse ib[][] is out of range of an array.
Can anyone help me?
thanks