Oh, I am sorry, I missed your reply. Yes, I did sort the data. I will review full code again,…