hdf_sort_obj (3) - Linux Manuals

hdf_sort_obj: sort the children of an HDF node

NAME

hdf_sort_obj - sort the children of an HDF node

SYNOPSIS

#include <util/neo_hdf.h>

hdf_sort_obj()

ARGUMENTS

h - HDF node
compareFunc - function which returns 1,0,-1 depending on some
criteria. The arguments to this sort function
are pointers to pointers to HDF elements. For
example:
int sortByName(const void *a, const void *b) {
HDF **ha = (HDF **)a;
HDF **hb = (HDF **)b;
*
return strcasecmp(hdf_obj_name(*ha), hdf_obj_name(*hb));
}
*

DESCRIPTION

hdf_sort_obj will sort the children of an HDF node, based on the given comparison function. This function works by creating an array of the pointers for each child object of h, using qsort to sort that array, and then re-ordering the linked list of children to the new order. The qsort compare function uses a pointer to the value in the array, which in our case is a pointer to an HDF struct, so your comparison function should work on HDF ** pointers.

RETURN VALUE

None (h children will be sorted)