# Thread: how to sort the scores(small to large)

1. ## how to sort the scores(small to large)

Acutally i have 10 good scores:
23 5 87 29 87 0 100 55 33 23

how can i sort good score in ascendant order(samll to large)

here is my code:

Code:
```void soreScores(ofstream& outdata, int listThree[])
{
int counter;
int x = 0;

outdata << "Sorted good scores:";
outdata << endl;

for (counter = 0; counter < 10; counter++)
{
if (listThree[x] <= listThree[counter])
{
listThree[x] = listThree[counter];
outdata << setw(4) <<listThree[x];
}
}
}```

2. Here's an extremely easy way:
Code:
```#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
int nums[]={24,72,34,11,82,7,25,92,0,10,6};
for(int i=0;i<11;i++)
cout<<nums[i]<<" ";
sort(nums,nums+11);
cout<<endl<<endl;
for(int b=0;b<11;b++)
cout<<nums[b]<<" ";
cout<<endl;
system("PAUSE");
return 0;
}```
In the example I make an array of numbers, use the sort algorithm, and it's now sorted from smallest to largest.

3. Code:
```void Bubblesort(int arr[],const int size)
{
for(int i=size-1;i>0;i--)
{
for(int i=0;i<size;i++)
{
if(arr[i]>arr[i+1])
swap(arr[i],arr[i+1]);
}
}
}```
just whipped it up then, try on ur code

Popular pages Recent additions