i have 5 source.txt in an 2D array i need to sort

my problem is that i use 2D array to store the information of each one of my source.txt so the first[] is use to store the number inside the txt and the second [] is used to index what source is what so for example source 1 is in [][0].. source 2 is in [][1] and so on my problem is that now i need to sort that but i do not know how to initialize it to do quick sort with it please help me this is my code so far...

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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <iostream>
#include <vector>
#include <math.h>
#include <fstream>
#include <ctime>
#include <iomanip>

using namespace std;

void quickSort(int arr[], int left, int right) {
      int i = left, j = right;
      int tmp;
      int pivot = arr[(left + right) / 2];
 
      /* partition */
      while (i <= j) {
            while (arr[i] < pivot)
                  i++;
            while (arr[j] > pivot)
                  j--;
            if (i <= j) {
                  tmp = arr[i];
                  arr[i] = arr[j];
                  arr[j] = tmp;
                  i++;
                  j--;
            }
      };
 
      /* recursion */
      if (left < j)
            quickSort(arr, left, j);
      if (i < right)
            quickSort(arr, i, right);
}

void printSorted(int array[], int length)
{
    for(int i=0;i<length;i++)
        cout<<array[i]<<"\n";
}

int main()
{
	int i = 0;
	int total = 0;
	int num;
	int arry [10000][6];
	int temp [6] = {0};
	int count = 0;
	int left = 0;
	int right = 10000;
	fstream data1;
	fstream data2;
	fstream data3;
	fstream data4;
	fstream data5;

	//Take in data and put it into the array
	data1.open("source1.txt", ios::in);
	count = 0;
	while(data1 >> num)
	{
		arry[count][0] = num;
		count++;
	}	
	data1.close();

	data2.open("source2.txt", ios::in);
	count = 0;
	while(data2 >> num)
	{
		arry[count][1] = num;
		count++;
	}	
	data2.close();

	data3.open("source3.txt", ios::in);
	count = 0;
	while(data3 >> num)
	{
		arry[count][2] = num;
		count++;
	}	
	data3.close();

	data4.open("source4.txt", ios::in);
	count = 0;
	while(data4 >> num)
	{
		arry[count][3] = num;
		count++;
	}	
	data4.close();

	data5.open("source5.txt", ios::in);
	count = 0;
	while(data5 >> num)
	{
		arry[count][4] = num;
		count++;
	}	
	data5.close();

	//Sum the rows across to get the ideal rank
	for (int i = 0; i < 10000; i++)
	{
		total = 0;
		for (int j = 0; j < 5; j++)
		{
			total += arry[i][j];
		}

		arry[i][5] = total;

	}

	
	//Use insertion sort to get each row sorted according to the ideal rank
	for(int i = 1; i < 10000; i++)
	{
		for(int j = 0; j < i; j++)
		{
			if(arry[i][5] < arry[j][5])
			{
				for(int k = 0; k < 6; k++)
				{
					temp[k] = arry[i][k];
				}

				for(int k = 0; k <6; k++)
				{
					arry[i][k] = arry[j][k];
					arry[j][k] = temp[k];
				}
			}
		}
	}
   
   quickSort(arry, 0, 10000 - 1);

   cout<<"-------------Sorted Array---------------\n";
   printSorted(arry,10000); 

    return 0;
}


the quicksort is not working i know that is completely wrong because i do not know what to do there or how to initialize variable so that it can work thank you
Topic archived. No new replies allowed.