Sorting data from file into array

I am suppose to read ints from a text file and sort them as I insert them into an array of size 10 without going out of bounds.

Doing that was not a problem, but I was told I need to read the WHOLE text file and sort data, but the data must be sorted BEFORE being put into an array, I do not see how this is possible with an array of only 10 and a text file with 15 digits. How can my program know if one of the numbers beyond 10 should or should not be in the array?

Also I am not allowed to use any advanced sorting functions..so I am at a complete loss. Any help would be appreciated, Thanks!

this is what I did.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
void sortArray(int iArray[])
{
	string fileName = "";
	fstream inFile;
	int tmp = 0;
	int size = 10;
	
	//Prompt user to input the name of the file
	cout << "please enter file name: ";
	cin >> fileName;

	//Open file
	inFile.open(fileName);
	 int j  = 0;
	 int i = 0;
	//Insertion sort, compares data as its read to the array and swaps numbers if needed


		while( !inFile.eof() && i < size)
		{
			
			inFile >> tmp;
			iArray[i] = tmp;
			 j = i;

			while (j > 0 && iArray[j-1] > iArray[j])
			{
				swap(iArray[j], iArray[j-1]);
				j--;
			}		   				
			i++;
		}

		inFile.close();
}
Topic archived. No new replies allowed.