From 89c3619ff69f9028976691c0467945ab1ad0f538 Mon Sep 17 00:00:00 2001 From: Gregory Gauthier Date: Fri, 30 Jan 2026 15:21:57 +0000 Subject: [PATCH] fix the sort order problem on cndump --- src/cndump.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/cndump.c b/src/cndump.c index 3cca255..502baf7 100644 --- a/src/cndump.c +++ b/src/cndump.c @@ -399,6 +399,18 @@ int main(int argc, char *argv[]) { else if (sort_mode == SORT_CATEGORY) { qsort(entries, entry_count, sizeof(Entry), compare_by_category); } + else if (g_sort_order == 1) { + /* No sort mode but -r specified: reverse the natural order */ + int left = 0; + int right = entry_count - 1; + while (left < right) { + Entry temp = entries[left]; + entries[left] = entries[right]; + entries[right] = temp; + left++; + right--; + } + } /* Calculate dynamic text width based on terminal */ g_text_width = calc_text_width(get_terminal_width());