diff options
| author | Leandro Pereira <leandro@hardinfo.org> | 2016-07-31 19:13:10 -0300 | 
|---|---|---|
| committer | Leandro Pereira <leandro@hardinfo.org> | 2016-07-31 19:16:57 -0300 | 
| commit | 821329d5d0ca126f8e22caa4591648f1f74e548a (patch) | |
| tree | 2a996e02bbb9a027b2da51abc52e42681a723023 /shell | |
| parent | e9673ed5d5cb56fcb9e9c4167c77553d0a1f38b3 (diff) | |
Fix sorting of benchmark results
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/shell.c | 27 | 
1 files changed, 17 insertions, 10 deletions
| diff --git a/shell/shell.c b/shell/shell.c index 9e38b0ce..87abc5c8 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -856,7 +856,13 @@ static gboolean rescan_section(gpointer data)      return entry->selected;  } -gint +static gint +compare_float(float a, float b) +{ +    return (a > b) - (a < b); +} + +static gint  info_tree_compare_val_func(GtkTreeModel * model,  			   GtkTreeIter * a,  			   GtkTreeIter * b, gpointer userdata) @@ -867,15 +873,16 @@ info_tree_compare_val_func(GtkTreeModel * model,      gtk_tree_model_get(model, a, INFO_TREE_COL_VALUE, &col1, -1);      gtk_tree_model_get(model, b, INFO_TREE_COL_VALUE, &col2, -1); -    if (col1 == NULL || col2 == NULL) { -	if (col1 == NULL && col2 == NULL) -	    return 0; - -	ret = (col1 == NULL) ? -1 : 1; -    } else { -	ret = shell->_order_type ? (atof(col1) < atof(col2)) : -	    (atof(col1) > atof(col2)); -    } +    if (!col1 && !col2) +        ret = 0; +    else if (!col1) +        ret = -1; +    else if (!col2) +        ret = 1; +    else if (shell->_order_type) +        ret = compare_float(atof(col1), atof(col2)); +    else +        ret = compare_float(atof(col2), atof(col1));      g_free(col1);      g_free(col2); | 
