开发者

Sort Hash Tables Glib - qsort

开发者 https://www.devze.com 2022-12-22 19:46 出处:网络
I\'m trying to sort a GLib hash table by id that looks something like: key - id { \"Red\",2, \"BLue\",4, \"Yellow\",5,

I'm trying to sort a GLib hash table by id that looks something like:

key - id
    {
    "Red",     2,
    "BLue",    4,
    "Yellow",  5,
    "Orange",开发者_开发百科  8
    } 

I'm just not sure how to approach this because GLib does not have a sort method. I was thinking to use qsort or GCompareFunc

Any ideas will be appreciate it!


Hash tables aren't supposed to be sorted. You should get a GList* from the g_hash_table_get_keys (or values if that's what you're sorting) and sort that. Also, be careful about confusing glibc and GLib.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号