diff --git a/core/views/caves.py b/core/views/caves.py index fdbca4a..dd621aa 100644 --- a/core/views/caves.py +++ b/core/views/caves.py @@ -69,14 +69,18 @@ def padnumber(x): def numericalcmp(x, y): return cmp(padnumber(x), padnumber(y)) -def caveKey(x): - """python3 function for sort. Done in a hurry. - Note that cave kataster numbers are not always integers. - This needs to be fixed make a decent sort order. +def caveKey(c): + """This function goes into a lexicogrpahic sort function, and the values are strings, + but we want to sort numberically on kataster number before sorting on unofficial number. """ - if not x.kataster_number: - return "~" - return x.kataster_number + if not c.kataster_number: + return "9999." + c.unofficial_number + else: + if int(c.kataster_number) >= 100: + return "99." + c.kataster_number + if int(c.kataster_number) >= 10: + return "9." + c.kataster_number + return c.kataster_number def getnotablecaves(): notablecaves = [] diff --git a/templates/caveindex.html b/templates/caveindex.html index 817ec5c..b4c4ee3 100644 --- a/templates/caveindex.html +++ b/templates/caveindex.html @@ -17,20 +17,22 @@
{% if cave.kataster_number %}{{ cave.kataster_number }} {{cave.official_name|safe}} {% if cave.unofficial_number %}({{cave.unofficial_number }}){% endif %}{% else %}{{cave.unofficial_number }} {{cave.official_name|safe}} {% endif %} |
New Cave
Cave Number Index - kept updated