/* Copyright (c) 2001-2009 by SoftIntegration, Inc. All Rights Reserved */
/* a sample program that sorts a list of integers and 
displays the result. */ 
#include <stdio.h>
#include <stdlib.h>

int num[10] = { 1,3,6,5,8,7,9,6,2,0};
int comp(const void *,const void *);

int main() {
    int i;
    
    printf("Original array:\t");
    for(i=0; i<10; i++)
        printf("%d ",num[i]);
    qsort(num,10,sizeof(int),comp);
    printf("\nSorted array:\t");
    for(i=0; i<10; i++) 
        printf("%d ",num[i]);
    printf("\n");
}

/* compare the integers */
int comp(const void *i, const void *j) {
    return *(int *)i - *(int *)j;
}
