move the hash, sort and avl to util.go
restructure KeyValue code