function node_import_sort in Node import 6
Function used by uasort to sort structured arrays by weight.
Related topics
1 string reference to 'node_import_sort'
- node_import_fields in ./
node_import.inc - Returns a list of available content fields for given node_import type.
File
- ./
node_import.inc, line 1497 - Public API of the Node import module.
Code
function node_import_sort($a, $b) {
$a_group = is_array($a) && isset($a['group']) ? $a['group'] : '';
$b_group = is_array($b) && isset($b['group']) ? $b['group'] : '';
if ($a_group !== $b_group && ($a_group === '' || $b_group === '')) {
return $a_group === '' ? -1 : 1;
}
$a_weight = is_array($a) && isset($a['weight']) ? $a['weight'] : 0;
$b_weight = is_array($b) && isset($b['weight']) ? $b['weight'] : 0;
if ($a_weight == $b_weight) {
return 0;
}
return $a_weight < $b_weight ? -1 : 1;
}