sort.c
author viric@llimona
Sun, 02 Sep 2007 16:01:27 +0200
changeset 27 153c479aa0bc
parent 4 b2dfe3374454
permissions -rw-r--r--
LEGUMIN kaj aliaj gxisdatigoj.

#include <stdio.h>
#include <stdlib.h>
#include "dictre.h"

extern struct Word words[];
extern int nwords;

static int cmp_words(const void *v1, const void *v2)
{
    struct Word *w1 = (struct Word *) v1;
    struct Word *w2 = (struct Word *) v2;

    return strcmp(w1->w, w2->w);
}

int sort_words()
{
    printf("Sorting...\n");
    qsort(words, nwords, sizeof(words[0]), cmp_words);
}