1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-08-17 20:00:10 +02:00

stats: write known apks in natural order

By using natural instead of alphabetical sorting, we support sorting by
vercodes properly and thus app versions show in the correct order.
This commit is contained in:
Daniel Martí 2015-08-28 18:28:39 -07:00
parent f4cbb6b3f8
commit 05316e3292

View File

@ -1654,6 +1654,10 @@ def scan_source(build_dir, root_dir, thisbuild):
return count
def natural_key(s):
return [int(sp) if sp.isdigit() else sp for sp in re.split(r'(\d+)', s)]
class KnownApks:
def __init__(self):
@ -1684,7 +1688,7 @@ class KnownApks:
lst.append(line)
with open(self.path, 'w') as f:
for line in sorted(lst):
for line in sorted(lst, key=natural_key):
f.write(line + '\n')
# Record an apk (if it's new, otherwise does nothing)