sort references by date for packing; newer commits should be processed first
diff --git a/lib/repository_admin.c b/lib/repository_admin.c
index c1adcc4..a2cd689 100644
--- a/lib/repository_admin.c
+++ b/lib/repository_admin.c
@@ -75,6 +75,11 @@ get_reflist_object_ids(struct got_object_id ***ids, int *nobjects,
*ids = NULL;
*nobjects = 0;
+ err = got_reflist_sort(refs,
+ got_ref_cmp_by_commit_timestamp_descending, repo);
+ if (err)
+ return err;
+
*ids = reallocarray(NULL, alloc_chunksz, sizeof(struct got_object_id *));
if (*ids == NULL)
return got_error_from_errno("reallocarray");