diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h index 291cdf42517ac74bb8fac48ba7472d07e3b8764d..8f5cf8c8b03011d0315cef8d1c3619b84c135528 100644 --- a/include/asterisk/vector.h +++ b/include/asterisk/vector.h @@ -387,6 +387,16 @@ int ast_vector_string_split(struct ast_vector_string *dest, res; \ }) +/*! + * \brief Sort a vector in-place + * + * \param vec Vector to sort + * \param cmp A memcmp compatible compare function + */ +#define AST_VECTOR_SORT(vec, cmp) ({ \ + qsort((vec)->elems, (vec)->current, sizeof(typeof((vec)->elems[0])), cmp); \ +}) + /*! * \brief Remove an element from a vector by index. *