Organizing an Array

How would you go about *most efficiently* organizing an int array from smallest to largest number. Here's a quick example code, has no error checking and is very literal, just used for an example.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

using namespace std;

int main()
{
    int ary[20];
    int x;

    for( x = 0; x <= 20; x++ )
    {
        printf( "%d: ", x );
        cin >> ary[x];
    }

    for ( x = 0; x <= 20; x++ )
      cout << ary[x] << endl;

    /* Organizing Code Here */
    cin >> x;
}
Pfft. Done it a thousand times.
 
void qsort(int *array,int beg,in...


Wait a second.
How would you go about *most efficiently* organizing an int array from smallest to largest number. Here's a quick example code, has no error checking and is very literal, just used for an example.
I don't believe you. This seems like a cleverly disguised homework question.
You post the first example.
How would you go about *most efficiently* organizing an int array from smallest to largest number
I wouldn't go to the *most efficient* way but for the *less typing* with already made STL algorithms
Topic archived. No new replies allowed.