[FIX] check if the key is present in the result before sort result on it

check if the key is present in the result before sort result on it