Last active
February 16, 2016 21:07
-
-
Save bel1k0v/9870806 to your computer and use it in GitHub Desktop.
max-children-sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getMaxDepth(node) { | |
var max; | |
if (node.children) { | |
var c = node.children.length; | |
max = node.children[0].depth; | |
for (var i = 0; i < c; ++i) { | |
max = getMaxDepth(node.children[i]); | |
} | |
} else { | |
max = node.depth; | |
} | |
return max; | |
} | |
return getMaxDepth(a) > getMaxDepth(b) ? 1 : -1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment