LinkedList Object Array Swapping

I am having trouble trying to do a simple selection sort for a LinkedList array that contains big integers.

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
void selectionSort(LinkedList list[], int size)
{
	int min; //element of minimum
	for (int i = 0; i < size - 1; i++)
	{
		min = i;
		for (int j = i + 1; j < size; j++)
		{
			if (list[j] < list[min])
				min = j;
		}
		if (min != i)
		Swap(list[min], list[i]);
	}
}
  	LinkedList* numbers = new LinkedList[lineCounter]; 
	lineCounter = 0; 
	while (getline(inFile, line))
	{
		bool negative = false;
		if (line[0] == '-')
		{
			negative = true;
			line.substr(0,1);
		}
		LinkedList temp(line, 1);
		numbers[lineCounter] = temp;
		if (negative == true)
			numbers[lineCounter].getHead()->num * -1;
		lineCounter++;
	}

The input file to sort:
36753562912709360626
18792023759228973612
93194784503610632061
55476569374525474430
78688431492068926649
50487172722610615949
19177115977673656394
81293908850963856115
98481030444476317596
21785741859753883189

My print function givs this as the output:
367535629127093606261879202375922897361236753562912709360626
1879202375922897361236753562912709360626191771159776736563941879202375922897361236753562912709360626
931947845036106320612178574185975388318993194784503610632061
55476569374525474430
786884314920689266495048717272261061594978688431492068926649
5048717272261061594978688431492068926649812939088509638561155048717272261061594978688431492068926649
19177115977673656394187920237592289736123675356291270936062698481030444476317596191771159776736563941879202375922897361236753562912709360626
8129390885096385611550487172722610615949786884314920689266492178574185975388318993194784503610632061812939088509638561155048717272261061594978688431492068926649
98481030444476317596191771159776736563941879202375922897361236753562912709360626
2178574185975388318993194784503610632061812939088509638561155048717272261061594978688431492068926649
It looks like you have a problem with the output function not the sorting (which seems to be correct). Please post all of the relevant code so that we can reproduce the problem.

Why do you use the term LinkedList when it is actually an array?
Topic archived. No new replies allowed.