Skip to content
Snippets Groups Projects
Commit c533b5be authored by Dorian Merz's avatar Dorian Merz
Browse files

refs #17063 [master] sort hierarchy children naturally

parent 197e760d
No related merge requests found
...@@ -64,4 +64,29 @@ class NoCollections extends \VuFind\Hierarchy\TreeDataFormatter\Json ...@@ -64,4 +64,29 @@ class NoCollections extends \VuFind\Hierarchy\TreeDataFormatter\Json
} }
return parent::pickTitle($record, $parentID); return parent::pickTitle($record, $parentID);
} }
/**
* Sort Nodes
* Convert an unsorted array of [ key, value ] pairs into a sorted array
* of values.
*
* @param array $array The array of arrays to sort
*
* @return array
*/
protected function sortNodes($array)
{
// Sort arrays based on first element
$sorter = function ($a, $b) {
return strnatcmp($a[0], $b[0]);
};
usort($array, $sorter);
// Collapse array to remove sort values
$mapper = function ($i) {
return $i[1];
};
return array_map($mapper, $array);
}
} }
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