# 'Sorting' algorithm

• 11-02-2001
Dual-Catfish
'Sorting' algorithm
Code:

```#include <iostream.h> int main() {         int num;                cout << "Hey buddy how many numbers do you wanto enter?";         cin >> num;         cout << "\n";         float biggest;         float *arguments = new float[num];                 for (int i=0; i<num; i++)         {                 cout << "Enter some numbers from my crazy algorithm to sort ->";                 cin>>arguments[i];                 cout << "\n";         }         for (i=arguments[i-1]; i>0; i--)         {                 for (int j=0; j<num; j++)                 {                         if (arguments[j] > arguments[i])                         {                                 biggest = arguments[j];                         }                         else                         {                                 biggest = arguments[i];                         }                 }         }         cout << "The Biggest number was: " << biggest;         int stop;         cin>>stop;         return 0; }```
There's a small problem with this sorting algorithm i dished up, based somewhat on bubblesort, although it doesn't work..
• 11-02-2001
DavidP
Use the quick sort...its much faster.
• 11-03-2001
Duck-Billed Platypus
eh?

>for (i=arguments[i-1]; i>0; i--)

so, your basing how many times you are going to loop on the value of arguments[i-1] ?
• 11-03-2001
Salem
for (i=num-1 ; i>0; i--)
for (int j=0; j<i; j++)

> if (arguments[j] > arguments[i])
At this point, you need to be swapping these two values, not just remembering which one is biggest.