Hello!
I got a 2d dynamic array to sort.
If i have for an example ar array like:
321
231
321
i want to sort it to:
123
123
123
How should I tweak my code to make it work? I can't find a similar example anywhere else, so I help someone can help!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
void sort(int **A,int n){
int row=0;
do{
for(int i=0;i<n-1;i++)
for(int j=1;j<n;j++)
if(A[row][i]>A[row][j])
swap(&A[row][i],&A[row][j]);
row++;
}while(row!=n+1);
}
void swap(int *num1, int *num2){
int temp = *num1;
*num1 = *num2;
*num2=temp;
}