buildTree's performances improvement

This patch should improve buildTree's performances.

I made sorting methods comparisons here : http://jsperf.com/sort-comparaison-function and I choose the best one for Chrome/Firefox/iPad/IE

It's not perfect, a limitation is that the dimensions array should be a list of words (you can's use "\{a *-" as key). But the performances gain is worth.