/* Collection of code snippets by Arne Vajhøj */
/* (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int a[4][2] = { {0,0}, {1,0}, {2,0}, {0,1} };

int main()
{
    int i,j,b[4],tmp;
    /* print */
    for(i=0;i<4;i++) printf("(%d,%d)",a[i][0],a[i][1]);
    printf("\n");
    /* construct array with random numbers */
    srand(time(NULL));
    for(i=0;i<4;i++) b[i] = rand();
    /* sort original array after random array */
    for(i=0;i<3;i++)
        for(j=(i+1);j<4;j++)
            if(b[i]>b[j])
            {
                tmp = b[i];
                b[i] = b[j];
                b[j] = tmp;
                tmp = a[i][0];
                a[i][0] = a[j][0];
                a[j][0] = tmp;
                tmp = a[i][1];
                a[i][1] = a[j][1];
                a[j][1] = tmp;
            }
    /* print */
    for(i=0;i<4;i++) printf("(%d,%d)",a[i][0],a[i][1]);
    printf("\n");
    return 0;
}
