summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-12-14 00:57:31 (EST)
committer graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-12-14 00:57:31 (EST)
commit0166b039680ca27ed48677680be4fe10846613a4 (patch)
tree7dee1d210c7ec365ef7144757ae3bf4769d5da08
parentb9f63a0992591fb76cb50e898579ad5718c7ef92 (diff)
Sort packages before listing them.
git-svn-id: http://opkg.googlecode.com/svn/trunk@490 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r--libopkg/opkg.c17
1 files changed, 17 insertions, 0 deletions
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;