updating binary tree and adding sort (heap)