sort an array of type int arry[MAX] using stl

how to sort an array of type int arry[MAX] using stl
where MAX is defined already and we know the number of entries in the array?

1
2
3
4
5
6
7
8
#define MAX 50000;
int main(){
int arry[MAX];
//after doing some insertion size of final array is size=a some value that we know
//now i want to sort it using some library function is there any function such kind 
return 0;
}
Something like this?
http://www.cplusplus.com/reference/algorithm/sort/

Hope that helps.
can we do the same for an array, in above link they have used it for a vector?
thanks!
Last edited on
hey! i am not able to do it for an array it is saying that begin() and end() are not define?
here's the code
1
2
3
4
5
6
7
8
9
10
11
12
13
#include<iostream>
#include<algorithm>
using namespace std;


int main(){
	int arry[5];
	arry[0]=5;
	arry[1]=2;	
	sort(begin(arry),end(arry));
	cout<<arry[0]<<arry[1]<<endl;
return 0;
}
Last edited on
can we do the same for an array, in above link they have used it for a vector?


Yes:
http://ideone.com/gZ4W7T

Of course, you need to account for the size of your array, my example was thrown together quickly.

Hope that helps.
thanks!
Topic archived. No new replies allowed.