int a[100][100],n,m,vect[100],v=1;
void copy(int a[][100],int n,int m,int vect[]){
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
vect[v++]=a[i][j];
}
void sort(int vect[]){
int aux;
for(int i=1;i<v-1;i++)
for(int j=i+1;j<v;j++)
if(vect[i]>vect[j]){
aux=vect[i];
vect[i]=vect[j];
vect[j]=aux;
}
}
void sort_2d_array(int a[][100],int n, int m, int vect[]){
copy(a,n,m,vect);
sort(vect);
for(int i=1;i<v;i++)
cout<<vect[i]<<" ";
cout<<endl;
}
This should help! With these 3 functions you can sort any 2d array you want! If you have any questions feel free to ask me. Btw the code here was made simple and is not very fast so if you want a fast code then you can use merge sort as a sorting method!
"I haven't learned vector yet..... T.T" Well ofcourse you did because "int sorted[cols] " is actually a vector. Vector or array is the same thing. Oh and btw shouldn't you use unsorted[rows][i]? If you have problems with arrays you can use this tutorial http://www.cplusplus.com/doc/tutorial/arrays/ . Also I am sorry if I can't explain myself because my english is quite bad. Well good luck at you program and feel free to ask me!
In my language vector or array is the same thing. We call an array vector or "tablou" (it means array). So sorry for generating confusing on this topic. Next time I will say array not vector : )
A vector is NOT the same as an array. Hell, there's even std::array. Vector is a container for contiguous memory that changes size of the contained memory. std::array and a normal array is not. When used in other languages, it simply means that the construct used is built to easily change size (although know that changing the size of contiguous memory is generally slow!).