From the input 'red blue green yellow', which word is the last in the final output?

Answer: D. yellow
After rearranging alphabetically, 'yellow' is the last word.