summaryrefslogtreecommitdiff
path: root/src/shared/strv.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/strv.c')
-rw-r--r--src/shared/strv.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/strv.c b/src/shared/strv.c
index 822b2dc888..1b8e27bc1b 100644
--- a/src/shared/strv.c
+++ b/src/shared/strv.c
@@ -735,3 +735,18 @@ bool strv_overlap(char **a, char **b) {
return false;
}
+
+static int str_compare(const void *_a, const void *_b) {
+ const char **a = (const char**) _a, **b = (const char**) _b;
+
+ return strcmp(*a, *b);
+}
+
+char **strv_sort(char **l) {
+
+ if (strv_isempty(l))
+ return l;
+
+ qsort(l, strv_length(l), sizeof(char*), str_compare);
+ return l;
+}