/* 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>

#define N 10000

void selectsort(int *a, int n)
{
    int i,j,ix,tmp;
    for(i=0;i<(n-1);i++)
    {
        ix = i;
        for(j=(i+1);j<n;j++) if(a[j]<a[ix]) ix=j;
        tmp = a[ix];
        a[ix] = a[i];
        a[i] = tmp;
    }
}

int main()
{
   int i,a[N];
   srand(time(NULL));
   for(i=0;i<N;i++) a[i]=rand();
   selectsort(a,N);
   for(i=0;i<N;i++) printf("%d\n",a[i]);
   return 0;
}
