Download the PHP package waughj/flat-to-hierarchy-sorter without Composer
On this page you can find all versions of the php package waughj/flat-to-hierarchy-sorter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package flat-to-hierarchy-sorter
Flat to Hierarchy Sorter
Sorts flat list of nodes with IDs and parent IDs into layered list of nodes with IDs and lists of children to make iteration easier.
Example
use WaughJ\FlatToHierarchySorter\FlatToHierarchySorter;
use WaughJ\FlatToHierarchySorter\HierarchicalNode;
$old_list =
[
new HierarchicalNode( 1, 0 ),
new HierarchicalNode( 2, 1 ),
new HierarchicalNode( 3, 1 ),
new HierarchicalNode( 4, 2 )
];
$sorted_list = FlatToHierarchySorter::sort( $old_list );
will return to equivalent of:
new HierarchicalNode
(
1,
0,
[
new HierarchicalNode( 2, 1, [ new HierarchicalNode( 4, 2 ) ] ),
new HierarchicalNode( 3, 1 )
]
);
Changelog
0.1.0
- Initial release
All versions of flat-to-hierarchy-sorter with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.2
The package waughj/flat-to-hierarchy-sorter contains the following files
Loading the files please wait ....