How can i apply inbuilt sort() in dynamically allocated array;

#include<iosteam>
#include<algorithm>
using namespace std;
int main()
{
 int *a=new int[5]{1,2,3,4,5};

return 0;
}

Hey
It will be same as that with static array
sort(arr,arr+n);

arr will pass on the address of static variable created inside the static memory. thus not getting correct ans

Hey @sagar_aggarwal


check this