By now, the fastest comparison sorting algorithm is \(Ο(N\log N)\). The sort()
function in STL implemented with an optimized quicksort, which is always \(O(N\log N)\).
Here is an example:
cpp How To Use STL Sort
#include <algorithm>
using namespace std;
#define N 20
int a[N];
bool cmp(int x, int y){
return x < y;
}
int main() {
sort(a, a + N, cmp);
return 0;
}