Sort packages before listing them.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 14 Dec 2009 05:57:31 +0000 (05:57 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 14 Dec 2009 05:57:31 +0000 (05:57 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@490 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg.c

index 7f9862b7a235ea96e5046e5a66359ea4fc7eb436..2321092e9f484efadbc38d2fe1f346d53594fb91 100644 (file)
@@ -697,6 +697,20 @@ opkg_update_package_lists(opkg_progress_callback_t progress_callback,
        return result;
 }
 
+static int
+pkg_compare_names_and_version(const void *a0, const void *b0)
+{
+       const pkg_t *a = *(const pkg_t **)a0;
+       const pkg_t *b = *(const pkg_t **)b0;
+       int ret;
+
+       ret = strcmp(a->name, b->name);
+
+       if (ret == 0)
+               ret = pkg_compare_versions(a, b);
+
+       return ret;
+}
 
 int
 opkg_list_packages(opkg_package_callback_t callback, void *user_data)
@@ -708,6 +722,9 @@ opkg_list_packages(opkg_package_callback_t callback, void *user_data)
 
        all = pkg_vec_alloc();
        pkg_hash_fetch_available(all);
+
+       pkg_vec_sort(all, pkg_compare_names_and_version);
+
        for (i = 0; i < all->len; i++) {
                pkg_t *pkg;