We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 5e21866 + d05e346 commit 9a47f90Copy full SHA for 9a47f90
CPP/vector-concepts/vectorSort.cpp
@@ -0,0 +1,26 @@
1
+// inbuilt sorting in vector
2
+```
3
+#include<bits/stdc++.h>
4
+using namespace std;
5
+int main(){
6
+//sort() can be used to sort array or vector or a string. gcc_sort hybrid algorithm. O(NlogN)
7
+
8
+//int a[n]; sort(a,a+n);
9
10
+//vector<int>v; sort(v.begin(), v.end());
11
12
+//string s; sort(s.begin(), s.end());
13
14
+//sort(ptr to 1st element, ptr to last element+1)
15
+int a[4]={5,4,1,2};
16
+//sort(a, a+3); output: 1 4 5 2
17
18
+// sort(a, a+4); //output 1 2 4 5
19
+// for(int i=0; i<4; i++){ cout<<a[i]<<" ";}
20
21
+vector<int>v={5,4,1,2};
22
+sort(v.begin(), v.end());
23
+for(int i=0; i<4; i++){ cout<<v[i]<<" ";}
24
+return 0;
25
+}
26
0 commit comments