Commit 1a37f39f authored by Ad Schellevis's avatar Ad Schellevis

(mvc) fix text sorting on array field, closes https://github.com/opnsense/core/issues/1261

parent 3b73bd5d
......@@ -146,7 +146,13 @@ class ArrayField extends BaseField
$sortKey = '';
foreach ($fieldNames as $fieldName) {
if (array_key_exists($fieldName, $node->internalChildnodes)) {
$sortKey .= sprintf("%".$MAX_KEY_LENGTH."s ,", $node->$fieldName);
if (is_numeric((string)$node->$fieldName)) {
// align numeric values right for sorting, not perfect but works for integer type values
$sortKey .= sprintf("%".$MAX_KEY_LENGTH."s,", $node->$fieldName);
} else {
// normal text sorting, align left
$sortKey .= sprintf("%-".$MAX_KEY_LENGTH."s,", $node->$fieldName);
}
}
}
$sortKey .= $nodeKey; // prevent overwrite of duplicates
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment