hdf_sort_obj(3)
π hdf_sort_obj(3) π
okay bestie, gather round, we're talking about hdf_sort_obj from util/neo_hdf.h β yes it's a section 3 library call, yes it's iconic, no I will not be normal about it β¨
πΈ NAME πΈ
hdf_sort_obj β sort the children of an HDF node. that's it. that's the whole job. and it ATE. π
π SYNOPSIS π
#include <util/neo_hdf.h>
hdf_sort_obj()
she's simple, she's clean, she's lowkey mysterious about her parameters (we'll get there, bestie, keep reading π«Ά)
π¦ ARGUMENTS π¦
hβ an HDF node. your lil guy. the one whose children are about to get a glow-up reorder β¨compareFuncβ a function which returns1,0, or-1depending on some criteria. okay so the tea here is that the arguments to this sort function are pointers to pointers to HDF elements. like, a double pointer. i know. i know. but stay with me. 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));
}
*
see? you cast to HDF **, you deref once, you call hdf_obj_name on each, and strcasecmp does the vibes check for you. so slay. π₯
π DESCRIPTION π
hdf_sort_obj will sort the children of an HDF node, based on the given comparison function. periodt.
the way it actually works is genuinely kind of a serve: it creates an array of the pointers for each child object of h, uses qsort to sort that array, and then re-orders the linked list of children to match the new order. so like, temporary array era, then linked list glow-up. π
now here's the detail you can NOT skip: 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. double pointer. iykyk. if you write it with a single pointer you're gonna have a bad time, and not the cute kind. π
π RETURN VALUE π
None. as in, nothing. zero. void energy. but bestie, the h children will be sorted β that's the whole reward, the side effect IS the moment. β¨
π§ SEE ALSO π§
the whole friend group, fr fr:
hdf_set_symlink(3)hdf_get_valuef(3)compareFunc)(3)hdf_dump_str(3)hdf_get_int_value(3)hdf_read_string_ignore(3)hdf_copy(3)hdf_get_node(3)hdf_set_value(3)hdf_obj_child(3)hdf_read_string(3)hdf_set_buf(3)hdf_register_fileload(3)hdf_get_obj(3)hdf_get_attr(3)hdf_obj_top(3)hdf_dump_format(3)hdf_destroy(3)hdf_init(3)hdf_obj_value(3)hdf_write_string(3)hdf_set_valuevf(3)hdf_sort_obj(3)hdf_write_file_atomic(3)hdf_obj_attr(3)hdf_set_valuef(3)hdf_get_copy(3)hdf_write_file(3)hdf_get_valuevf(3)hdf_set_int_value(3)hdf_dump(3)hdf_get_value(3)hdf_set_copy(3)hdf_obj_next(3)hdf_search_path(3)hdf_obj_name(3)hdf_set_attr(3)hdf_get_child(3)hdf_remove_tree
(yes that last one is missing its (3) β i'm not touching it, it's part of the lore π)
and that's the page, bestie!! π this lil baddie is brought to you by ClearSilver, dated 12 July 2007 β yes she's vintage, yes she still hits, no notes. go sort something. ππ¦β¨
π¦ where this page comes from
- debian bookworm: clearsilver-dev 0.10.5-4+b5
- debian trixie: clearsilver-dev 0.10.5-6+b1
- epel 10: clearsilver 0.10.5-80.el10_2 Β· Apache-1.1
- epel 9: clearsilver 0.10.5-74.el9 Β· Apache-1.1
- fedora 43: clearsilver 0.10.5-80.fc43 Β· Apache-1.1
- fedora 44: clearsilver 0.10.5-82.fc44 Β· Apache-1.1
- ubuntu jammy: clearsilver-dev 0.10.5-4build3
- ubuntu noble: clearsilver-dev 0.10.5-4build7
- ubuntu questing: clearsilver-dev 0.10.5-6build1
- ubuntu resolute: clearsilver-dev 0.10.5-7
- ubuntu stonking: clearsilver-dev 0.10.5-7build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms