From 0b59e4ce379294c330157efab92ef4419531df25 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 26 Mar 2009 11:59:39 +0100 Subject: sort hills with equal names by height --- src/Hill.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Hill.cxx b/src/Hill.cxx index c2971cf..6404ec8 100644 --- a/src/Hill.cxx +++ b/src/Hill.cxx @@ -212,11 +212,17 @@ static int comp_mountains_name(const void *n1, const void *n2) { Hill *m1 = *(Hill **)n1; Hill *m2 = *(Hill **)n2; + int r; - if (m1 && m2) - return strcasecmp(m1->name, m2->name); - else + if (m1 && m2) { + r = strcasecmp(m1->name, m2->name); + if (r == 0) + return (int) (m1->height - m2->height); + else + return r; + } else { return 0; + } } void -- cgit v1.2.3