Use key function in comparekeys