Add two utils: sortbykey() and buildhier()