I want re-order my matrix in ascending order but it should be in row basis and I'm a little bit stuck and in trouble with it. Here what it looks like.

ex.

```
3 5 4
9 2 8
6 4 8

```

should be;

```
3 4 5
2 8 9
4 6 8

```

But with my code orders everything in ascending order!

```
2 3 4
4 5 6
8 8 9

```

Here is my full code:

```
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>

#define n 3

int main()
{
    int arr[n][n],min,i,j,tmp,y,k,w,z=0,q=0;
    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        {
            printf("Enter number: ");
            scanf("%d",&arr[i][j]);
        }

    for(i=0;i<n;i++)
        for(j=0;j<n;j++)
        {
            z = i;
            q = j;

            min = arr[i][j];
            w = j;

        for (k = i; k < n; k++)
        {
         for (; w < n; w++)
           if (arr[k][w] < min)
           {
            min = arr[k][w];
            z = k;
            q = w;
           }
         w = 0;
        }
       tmp=arr[i][j];
       arr[i][j]=min;
       arr[z][q]=tmp;
     }

    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
            printf("%d ",arr[i][j]);
        printf("\n");
    }
    getch();
}

```