### Sorting function repeating numbers?

MY SortArray function is sorting my numbers but repeating some of them twice, for example : 59 59, 60 60, etc. i cant seem to find the error

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125`` `````` #include #include #include #include #include using namespace std; void ZeroOutArray(int numbers[]); int GetSum(int numbers[]); /* GetData DisplayArray GetAverage GetStandardDeviation GetRandomElement GetHigh GetLow */ void SortArray (int numbers[]); int main() { //declare variables section string inputFile; ifstream inData; int sum,count=0,i=0; inData.open("ModerateTemps.dat"); /* cout << "Enter the input data file name: " << endl; cin >> inputFile; inData.open(inputFile.c_str()); if (!inData) { cout<< "Can't open the input file. Program is stopping." << endl; return 1; } */ const int MAX_TEMPS = 25; //be sure to use a constant when declaring the array int numbers[MAX_TEMPS] = {0}; //declare and zero out the array inData >> numbers[0]; //prime the loop with an initial read from the file count++; i++; while (count < MAX_TEMPS && inData >> numbers[i]) { count++; i++; } SortArray(numbers); for (int i=0; i<25; i++) { cout << numbers[i] << endl; } cout << GetSum(numbers); return 0; } //FUNCTION DEFINTIONS int GetSum( int numbers[]) { int sum=0; for (int i=0; i<25; i++) { sum+=numbers[i]; } return sum; } void SortArray (int numbers[]) { int n=25; for(int x=0; xnumbers[y]) { index_of_min = y; } } int temp = numbers[x]; numbers[x] = numbers[index_of_min]; numbers[index_of_min] = temp; } }``````
anyone? :(
Topic archived. No new replies allowed.