#include <stdio.h>          
#include <stdlib.h>
#include <string.h>

#define INT_ARRAY_COUNT 6
#define DOUBLE_ARRAY_COUNT 7
#define STRING_ARRAY_COUNT 5

int intComparator ( const void * first, const void * second ) {
    int firstInt = * (const int *) first;
    int secondInt = * (const int *) second;
    return firstInt - secondInt;
}

int doubleComparator ( const void * first, const void * second ) {
    double firstDouble = * (const double *) first;
    double secondDouble = * (const double *) second;
    return (int) (firstDouble - secondDouble);
}


int stringComparator(const void *first, const void *second) {
    const char *firstString = *(const char **)first;
    const char *secondString = *(const char **)second;
    return strcmp(firstString, secondString);
}


int main() {
    
    int intArray[] = { 10, 50, 30, 20, 40, 60 };
    double doubleArray[] = { 1.2, 6.4, 7.4, 2.9, 4.3, 5.6, 8.1 };
    char *stringArray[] = { "xx","jj","a","ag","mlkmqlk"};
    
    qsort( intArray, INT_ARRAY_COUNT, sizeof(int), intComparator );
    qsort( doubleArray, DOUBLE_ARRAY_COUNT, sizeof(double), doubleComparator );
    qsort( stringArray, STRING_ARRAY_COUNT, sizeof(char *), stringComparator );

    for( int i=0; i<INT_ARRAY_COUNT; i++ ) {
        printf( "%u - ", intArray[i] );
    }
    printf( "\n" );

    for( int i=0; i<DOUBLE_ARRAY_COUNT; i++ ) {
        printf( "%5.2lf - ", doubleArray[i] );
    }
    printf( "\n" );

    for( int i=0; i<STRING_ARRAY_COUNT; i++ ) {
        printf( "%s - ", stringArray[i] );
    }
    printf( "\n" );

    return 0;
}
