I have a temp data frame which has dates as below. I am trying to sort it with dates, but output is not coming correctly. For example, 20-May-2021 is coming at No4 in place of at top
This is because your date specification is failing to parse. Run only as.Date(temp$EXPIRY_DT, "%dd/%mmm/%YYYY") to see this. Change dd to d, mmm to B, and YYYY to just Y:
Great! Would you mind going ahead and marking it as a solution? That will let others know a solution was found when they're searching for the same problem!