-
Problem report
-
Resolution: Unresolved
-
Trivial
-
None
-
6.4.10, 7.0.0alpha9
-
None
Steps to reproduce:
- Add a couple of hosts, link to a template with numeric values
- create a top hosts widget
- Add a column for some numeric metric and leave the "Aggregation function" as 'none', and "Display" as "As is" and don't add any thresholds.
- The values appear to be sorted the opposite of what you'd expect based on the sorting option
- For an array of values ('500', '21', '104', '53'); TopN sorting results in an ascending sort where the ordering becomes 21, 53, 104, 500.
It appears that self::isNumericOnlyColumn($master_column) could use some work. For the metric I'm plotting its a known numeric item type, But it looks like that function expects that the display is not "As is" or the aggregation function is nont "none".
I think, unless I'm missing something here, the sorting logic is backwards in this block when doing SORT_NATURAL:
if ($this->fields_values['order'] == Widget::ORDER_TOP_N) { if ($master_items_only_numeric_present) { arsort($master_item_values, SORT_NUMERIC); $master_items_min = end($master_item_values); $master_items_max = reset($master_item_values); } else { asort($master_item_values, SORT_NATURAL); } } else { if ($master_items_only_numeric_present) { asort($master_item_values, SORT_NUMERIC); $master_items_min = reset($master_item_values); $master_items_max = end($master_item_values); } else { arsort($master_item_values, SORT_NATURAL); } }