diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2014-09-24 18:59:55 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2014-09-24 18:59:55 +0200 |
commit | 50e27cf3d83a17efe7d6ee7515d00716593a2a51 (patch) | |
tree | c9368533dbc81910c9e6215d7d5841c580fcdad1 | |
parent | 734931d84fd54f65fd8b2658829191ce101b10bb (diff) | |
download | ponymap-50e27cf3d83a17efe7d6ee7515d00716593a2a51.tar.gz ponymap-50e27cf3d83a17efe7d6ee7515d00716593a2a51.tar.xz ponymap-50e27cf3d83a17efe7d6ee7515d00716593a2a51.zip |
Order the results by port
-rw-r--r-- | ponymap.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1405,12 +1405,14 @@ target_dump_terminal (struct target *self, struct target_dump_data *data) } static int -unit_cmp_by_group (const void *ax, const void *bx) +unit_cmp_by_order (const void *ax, const void *bx) { const struct unit **ay = (void *) ax, **by = (void *) bx; const struct unit *a = *ay, *b = *by; int x = strcmp (a->service->name, b->service->name); - return x ? x : strcmp (a->transport->name, b->transport->name); + if (!x) x = strcmp (a->transport->name, b->transport->name); + if (!x) x = (int) a->port - (int) b->port; + return x; } static void @@ -1431,7 +1433,7 @@ target_dump_results (struct target *self) sorted[--len] = iter; // Sort them by service name so that they can be grouped - qsort (sorted, N_ELEMENTS (sorted), sizeof *sorted, unit_cmp_by_group); + qsort (sorted, N_ELEMENTS (sorted), sizeof *sorted, unit_cmp_by_order); if (ctx->json_results) target_dump_json (self, &data); |