diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-05-11 08:46:08 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-05-12 12:28:06 -0700 |
commit | 114b3d9d470e65c25bcb5711daf053478f30e319 (patch) | |
tree | 0d0d9d47cf972bb9c1148c3bb343b33006b80131 /core/divelist.c | |
parent | e362afe43ca4144838fd544bcb048d4a033690bc (diff) | |
download | subsurface-114b3d9d470e65c25bcb5711daf053478f30e319.tar.gz |
Core: consider dive-number on sorting
A user reports a problem when dives have the same time but different
numbers. The dives appear sorted randomly (effectively they are sorted
by an internal unique-id).
Try to sort by number for dives at the same date in this case.
Fixes #2086
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/divelist.c')
-rw-r--r-- | core/divelist.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/core/divelist.c b/core/divelist.c index f7a3f5643..9ae87a328 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -779,7 +779,7 @@ struct dive *last_selected_dive() * After editing a key used in this sort-function, the order of * the dives must be re-astablished. * Currently, this does a lexicographic sort on the - * (start-time, trip-time, id) tuple. + * (start-time, trip-time, number, id) tuple. * trip-time is defined such that dives that do not belong to * a trip are sorted *after* dives that do. Thus, in the default * chronologically-descending sort order, they are shown *before*. @@ -804,6 +804,10 @@ static int comp_dives(const struct dive *a, const struct dive *b) if (trip_date(a->divetrip) > trip_date(b->divetrip)) return 1; } + if (a->number < b->number) + return -1; + if (a->number > b->number) + return 1; if (a->id < b->id) return -1; if (a->id > b->id) |