add key to sort on and use external sorting