python/depanalysis: sort versions by version number, not frequency
- ID
57e5ee3- date
2026-08-09 11:06:32+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
9796569- message
python/depanalysis: sort versions by version number, not frequency This makes it easier for me to spot outdated/older versions of packages.- changed files
1 file, 7 additions, 1 deletion
Changed files
python/depanalysis.py (1518 → 1862)
diff --git a/python/depanalysis.py b/python/depanalysis.py
index c5c1431..9a14ff0 100755
--- a/python/depanalysis.py
+++ b/python/depanalysis.py
@@ -36,8 +36,14 @@ if __name__ == "__main__":
if len(tally) == 1:
print(f"{len(versions):3d} {package} {versions[0]}")
else:
+ # Break each version into a tuple of ints, then sort them.
+ # This will break for non-numeric versions but it's fine for
+ # now, and makes it easy to spot outdated packages.
+ sorted_versions = sorted(
+ tally.items(), key=lambda kv: tuple([int(p) for p in kv[0].split(".")])
+ )
version_info = ", ".join(
- f"{v_str} ({count})" for v_str, count in tally.most_common()
+ f"{v_str} ({count})" for v_str, count in sorted_versions
)
print(f"{len(versions):3d} {package} {coloured(version_info, 'blue')}")