improved 'sort' method on trees. Now working as a regular javascript sort function
merged with latest changes in lib/tree/tree.js