From fff44a99bdb49e2333ccee7a17b526e243cd3b02 Mon Sep 17 00:00:00 2001 From: lkrsnik Date: Fri, 30 Aug 2024 12:32:25 +0200 Subject: [PATCH] Added fix for sorting Ratio --- app.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app.py b/app.py index 51c709a..87541c1 100755 --- a/app.py +++ b/app.py @@ -158,13 +158,6 @@ def create_app(): } if 'Absolute frequency in second treebank' in head: table_columns2displayed_table_columns['Absolute frequency'] = gettext('Frequency in A') - # table_columns2displayed_table_columns['Absolute frequency in second treebank'] = gettext('Frequency in B') - # if 'MI' in table_columns2displayed_table_columns: - # del table_columns2displayed_table_columns['MI'] - # if 'logDice' in table_columns2displayed_table_columns: - # del table_columns2displayed_table_columns['logDice'] - # if 't-score' in table_columns2displayed_table_columns: - # del table_columns2displayed_table_columns['t-score'] else: del table_columns2displayed_table_columns['Absolute frequency in second treebank'] displayed_table_columns2table_columns = {v: k for k, v in table_columns2displayed_table_columns.items()} @@ -176,9 +169,9 @@ def create_app(): sort_id = head.index(order_by) if order_type == 'asc': # check if a number can be converted to float or int - ordered_content = sorted(content[1:], key=lambda x: -1 * float(x[sort_id]) if x[sort_id].isnumeric() or re.match(r'^-?\d+(?:\.\d+)$', x[sort_id]) is not None else x[sort_id], reverse=True) + ordered_content = sorted(content[1:], key=lambda x: -1 * float(x[sort_id]) if x[sort_id].isnumeric() or re.match(r'^-?\d+(?:\.\d+)$', x[sort_id]) is not None and order_by != 'Ratio' else x[sort_id], reverse=True) else: - ordered_content = sorted(content[1:], key=lambda x: -1 * float(x[sort_id]) if x[sort_id].isnumeric() or re.match(r'^-?\d+(?:\.\d+)$', x[sort_id]) is not None else x[sort_id]) + ordered_content = sorted(content[1:], key=lambda x: -1 * float(x[sort_id]) if x[sort_id].isnumeric() or re.match(r'^-?\d+(?:\.\d+)$', x[sort_id]) is not None and order_by != 'Ratio' else x[sort_id]) else: ordered_content = content[1:]