Hello kannansekar,
Thank you for reaching out in Apple Support Communities. We understand that files are properly organized on your Mac, until an external hard drive is connected. We'll be happy to help.
Are you noticing this behavior with files that are stored directly on your Mac or through the external hard drive? Just to be sure, have you followed the steps outlined in this helpful article, on how to organize your files: Organize your files in the Finder on Mac
If these steps are followed correctly, and it appears to occur with the files stored on your Mac, we recommend to restart the computer in safe mode. This helps to verify your startup disk, deletes some system caches and more. Once your Mac is in safe mode, please restart your Mac as normal and test to see if you continue to experience this behavior. If needed, here's how to restart your Mac in safe mode: How to use safe mode on your Mac
We look forward to hearing back from you with an update.
Kind regards.