From 36904e1612598d9f58ce1e199f6c24a0beaf1cce Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 3 Oct 2019 09:31:34 +0200 Subject: [PATCH] dict: add function to sort --- spa/include/spa/utils/dict.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spa/include/spa/utils/dict.h b/spa/include/spa/utils/dict.h index 50e641d34..272420ec3 100644 --- a/spa/include/spa/utils/dict.h +++ b/spa/include/spa/utils/dict.h @@ -62,6 +62,13 @@ static inline int spa_dict_item_compare(const void *i1, const void *i2) return strcmp(it1->key, it2->key); } +static inline void spa_dict_qsort(struct spa_dict *dict) +{ + qsort((void*)dict->items, dict->n_items, sizeof(struct spa_dict_item), + spa_dict_item_compare); + SPA_FLAG_SET(dict->flags, SPA_DICT_FLAG_SORTED); +} + static inline const struct spa_dict_item *spa_dict_lookup_item(const struct spa_dict *dict, const char *key) {