Cast keys to stop sort bug