DNAsorting
#include <iostream>
#define maxn 51
#define maxm 100
char a[maxm][maxn];
using namespace std;
void DNAsort(char a[maxm][maxn], int n, int m)
{
int co[maxm];
memset(co, 0, sizeof(co));
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
for (int p = j+1; p < n; p++)
{
if (a[i][j] > a[i][p])
co[i]++;
}
}
}
for (int i = 0; i < m; i++)
{
for (int j = i+1; j < m; j++)
{
if (co[i] < co[j])
continue;
else
{
int t;
t = co[i];
co[i] = co[j];
co[j] = t;
char temp[maxn];
for (int k = 0; k < n; k++)
{
temp[k] = a[i][k];
}
for (int k = 0; k < n; k++)
{
a[i][k] = a[j][k];
}
for (int k = 0; k < n; k++)
{
a[j][k] = temp[k];
}
}
}
}
}
int main()
{
memset(a, '\0', sizeof(a));
int n,m;
cin >> n >> m;
for (int i = 0; i < m; i++)
{
cin >> a[i];
}
DNAsort(a, n, m);
for (int i = 0; i < m; i++)
{
cout << a[i] << endl;
}
return 0;
}