/*************************************************************
/*
/* Program vorder
/*
/* This program contains an example of how to call the
/* function uti_vorder contained in the utility library.
/* It orders a vector according to order of another vector.
/*
/* E. Pasqualucci 4-10-1996
/*
/*************************************************************

/* standard include files */

#include <stdio.h>

/* prototype files */

#include "utilib_protos.h"

main()
{
/*  This is an example of how the user must call uti_vorder */

    register int i;

    int n;
    int *v1;
    unsigned char *v2;

    printf (" Number of components ? ");
    scanf ("%d", &n);

    v1 = (int *) calloc ((size_t) n, sizeof (int));
    v2 = (unsigned char *) calloc ((size_t) n, sizeof (unsigned char));

    printf (" Components of the vector to order (int):\n");

    for (i=0 ; i < n ; ++i)
        scanf ("%d", v1+i);

    printf (" Components of the vector giving the order (u_char):\n");

    for (i=0 ; i < n ; ++i)
        scanf ("%d", v2+i);

    uti_vorder ((void *) v1, (void *) v2, sizeof (int), n, uti_uc_comp);

    printf (" Ordered vector\n");

    for (i=0 ; i < n ; ++i)
        printf ("%d\n", v1[i]);
}