Replaced cmp with key in sorted