Displaying an Array, sorting with pointers, then displaying the original again in C
<p>I'm trying to display an array, make a copy of that array and copy the pointers, then sort the pointer array, then display the original array in the original order.
What am I doing wrong? I've been working on this for an entire day. The output looks like.</p>

<pre><code>Now displaying data in original order:
47 48 58 123 456 789 188 0 3000 47 939 
2373 1873 283 948 333 283 2835 248 444 555 
732 1983 473 939 3000 7 9 2496 1729 1776 
11 12 84 126 120  

Now displaying data in sorted order:
0 7 9 11 12 47 47 48 58 84 120 
123 126 188 248 283 283 333 444 456 473 
555 732 789 939 939 948 1729 1776 1873 1983 
2373 2496 2835 3000 3000  

Now displaying data in original order:
0 7 9 11 12 47 47 48 58 84 120 
123 126 188 248 283 283 333 444 456 473 
555 732 789 939 939 948 1729 1776 1873 1983 
2373 2496 2835 3000 3000 
</code></pre>

<p>Code:</p>

<pre><code>#include &lt;stdio.h&gt;
int bubblesort(int *arr,int n);
void display(int array[],int);
void ptrdisplay(int array[],int size);
void swap(int *x, int *y);

int main()
{
    int data[]={47,48,58,123,456,789,188,0,3000,47,939,2373,1873,283,948,333,283,2835,248,444,555,732,1983,473,939,3000,7,9,2496,1729,1776,11,12,84,126,120};
    int size= sizeof(data)/sizeof(data[0]);
    printf("Now displaying data in original order\n");
    display(data,size);

    int * ptrdata[size];

    for(int i=0;i&lt;size;++i)
    {
        ptrdata[i]=&amp;data[i];
    }

    bubblesort(*ptrdata, size);

    printf("\nNow displaying data in sorted order\n");
    ptrdisplay(*ptrdata, size);

    printf("\nNow displaying data in original order\n");
    display(data,size);

}

void display(int array[],int size)
{
    for(int i=0;i&lt;size;++i)
    {
        printf("%d ",array[i]);
        if(i==10||i==20||i==30)
            printf("\n");
    }

    puts(" ");
}


void ptrdisplay(int array[],int size)
{
    for(int i=0;i&lt;size;++i)
    {
        printf("%d ",array[i]);
        if(i==10||i==20||i==30)
            printf("\n");
    }

    puts(" ");
}

void swap(int *x, int *y)
{
    int temp;
    temp = *x;
    *x   = *y;
    *y   = temp;
}


int bubblesort(int *arr,int n)
{
    int i,j;
    for(i=0;i&lt;(n-1);i++)
        for(j=0;j&lt;(n-1-i);j++)
        {
            if(*(arr+j)&gt;*(arr+(j+1)))
            {
                swap((arr+j), (arr+(j+1)));
            }
        }
    return 0;
}
</code></pre>