Thanks for the inputs but the problem was with the environment.
The app server used is WAS 7 and I found that there is a known issue, if someone is using the Arrays.sort API with an older build of SDK.
Please refer below link for details:
I found out that while updating the latest fix packs, the SDK fix packs were never updated and this caused the build of the SDK of the app server to remain old, which ultimately resulted in the behavior.
After installing the SDK fix pack the issue got resolved!
Thanks again for all your inputs.