Trouble sorting an array

Write your question here.

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
      #include "stdafx.h"
    #include <iostream>
    #include <math.h>
    #include <time.h>
    #include<iomanip>
    #include<array>
    #include <algorithm>
    
    using namespace std;
    const int AS = 6;
    void FillingRandomly(int [AS][AS]);
    void printing(int[AS][AS]);
    void forsorting(int[][AS], int);
    int c;
    
    int main()
    
    {
    	int funny = 0;
    	int timpa = 0;
    	int counter = 0;
    	int Array[AS][AS];
    	srand(time(0));
    
    
    	FillingRandomly(Array);
    	
    
    	cout << "The unsorted array is" << endl << endl;
    
    	printing(Array);
    
    
    	cout << "The sorted array is" << endl << endl;
    
    
    
    	forsorting(Array, funny);
    
    		printing(Array);
    
    	
    	
    	system("PAUSE");
    
    
    	return 0;
    
    }
    
    void FillingRandomly(int Array[AS][AS])
    {for (int i = 0; i<AS; i++)
    	{
    		for (int j = 0; j<AS; j++)
    			Array[i][j] = rand()%87 +12;
    	
    }
    }
    
    void printing(int Array[AS][AS])
    {
    	int counter = 0;
    	for (int i = 0; i<AS; i++)
    	{
    		for (int j = 0; j<AS; j++)
    		{
    			cout << setw(5) << Array[i][j];
    			counter++;
    			if (counter%AS == 0)
    				cout << endl << endl;
    		}
    	}
    }
    
    void forsorting(int Array[AS][AS], int funny)
    {
    
        int w=0;
    	int dice = 0;
    	int Brray[AS*AS];
    	int super = 0;
    	int space=0;
    	
    	
    
    	//Transofrming Array[][] into Brray[]
    	for (int i = 0; i < AS; i++)
    	{
    		for (int k = 0; k < AS; k++)
    		{
    			Brray[space] = Array[k][i];
    			space++;
    		}
    	}
    
    
    	//Bubble sorting in Brray[]
    
    	for (int passer = 0; passer < AS-1; passer++)
    	{
    		for (int timpa = 0; timpa < AS-1; timpa++)
    		{
    			if (Brray[timpa]>Brray[timpa + 1])
    			{
    				super = Brray[timpa];
    				Brray[timpa] = Brray[timpa + 1];
    				Brray[timpa + 1] = super;
    			}
    		}
    	}
    
    	//Transforming Brray[] into sorted Array[][]
    	
    for (int j=0;j<AS;j++)
    	for (int i=0;i<AS;i++)
    		{Brray[w]=Array[i][j];
    }
    w++;
    
    }

Ok so here's my code. All I need done is the sorting part, Ive written the bubble sorting technique, and i double checked my course and it was the same logic. So what I would like to know is why is my array not sorted when I print it out on the screen.

Thank you for your help
Are you required to write your own sorting method, or can you use the C++ std::sort function?
http://www.cplusplus.com/reference/algorithm/sort/
http://en.cppreference.com/w/cpp/algorithm/sort
What are lines 114 through 118 supposed to be doing?
Topic archived. No new replies allowed.