etrepat/baum — pull request #46 by shaddowgh (2014-03-04 14:05:50+00:00)
Title: allow custom sorting of toHierarchy result

allow custom sorting of toHierarchy result, using a arbitrary comparator
function with uasort. Fixes #41.
Possibly not as efficient as a pure SQL solution depending on the
complexity of the sort and the number or records but for simple
comparison its fairly elegant.

example to sort by "name" attribute of node
```
$sorted = Category::all()->toHierarchy(function($a,$b){ return
strcmp($a->name, $b->name);})
```