From 0166b039680ca27ed48677680be4fe10846613a4 Mon Sep 17 00:00:00 2001 From: "graham.gower" Date: Mon, 14 Dec 2009 05:57:31 +0000 Subject: [PATCH] Sort packages before listing them. git-svn-id: http://opkg.googlecode.com/svn/trunk@490 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358 --- libopkg/opkg.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libopkg/opkg.c b/libopkg/opkg.c index 7f9862b..2321092 100644 --- a/libopkg/opkg.c +++ b/libopkg/opkg.c @@ -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; -- 2.30.2