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());