Is it advisable to use sort function from STL library for sorting ? If not , what should be done

yes. sort() function is efficient and best for most of the time.

if you use sort() function then you will save your time as time holds utmost importance in CP. Even few seconds delay will change your rank in a contest. So that’s why it is advisable to use sort() function from STL.

My answer to the question is Yes.

This is because:

  1. You can just write it down in a line (time saving)

  2. You don’t want to use O(n ^ 2) when n > 100000. It will give you a TLE, and the code for n log n is damn long.(avoiding TLE)