From 2326f20a282d4625465bc213433973d1d644678a Mon Sep 17 00:00:00 2001 From: mARTin-B78 Date: Tue, 9 Jun 2026 22:37:17 +0200 Subject: [PATCH] fix: numeric sort for Time, Accuracy, RAM columns (v2.03.06) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit String sort put "14.85" before "2.47". Now uses a custom comparator that strips % and non-numeric markers before comparing as float. Non-numeric values ("—", "server") sort to the bottom. Co-Authored-By: Claude Sonnet 4.6 --- linux/blitztext/__init__.py | 2 +- linux/blitztext/gtksettings.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/linux/blitztext/__init__.py b/linux/blitztext/__init__.py index 93cad87..5779f81 100644 --- a/linux/blitztext/__init__.py +++ b/linux/blitztext/__init__.py @@ -6,4 +6,4 @@ counterpart to the macOS Blitztext menu bar app: it runs natively on the host (not in a container) so it can type into any application via xdotool. """ -__version__ = "2.03.05" +__version__ = "2.03.06" diff --git a/linux/blitztext/gtksettings.py b/linux/blitztext/gtksettings.py index 79378d2..ff50310 100644 --- a/linux/blitztext/gtksettings.py +++ b/linux/blitztext/gtksettings.py @@ -2058,6 +2058,17 @@ notebook.bt-nb tab:checked label { tree = Gtk.TreeView(model=bench_sort) tree.set_has_tooltip(True) tree.set_tooltip_column(10) + + # Numeric sort: strip %, "server", "—" then compare as float (non-numeric → inf) + def _num_cmp(model, a, b, col): + def _f(v): + try: + return float(v.rstrip("%")) + except (ValueError, AttributeError): + return float("inf") + va, vb = _f(model.get_value(a, col)), _f(model.get_value(b, col)) + return (va > vb) - (va < vb) + for title, i, expand, max_w in [ ("Engine", 0, False, 0), ("URL", 1, False, 180), @@ -2077,6 +2088,8 @@ notebook.bt-nb tab:checked label { if max_w: col.set_max_width(max_w) tree.append_column(col) + if i in (6, 7, 8): # Time, Accuracy, RAM — sort numerically + bench_sort.set_sort_func(i, _num_cmp, i) tree_sw = Gtk.ScrolledWindow() tree_sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) tree_sw.add(tree)