updated sort key generation