Add hashSortByVale and removeSelf utils and refactor codes.