Given a string S consisting of lowercase latin letters, arrange all its letters in ascending order.
Input:
The first line of the input contains T denoting number of testcases.Then follows description of each testcase.The first line of the testcase contains positive integer N denoting the length of string.The second line contains the string S.
Output:
For each testcase,output the sorted string.
Constraints:
1<=T<=100
1<=N<=100
1<=N<=100
Example:
Input:
1
5
edcab
1
5
edcab
Output:
abcde
abcde
Your Code
#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
string a;
int n;
cin>>n;
cin.ignore();
getline(cin,a);
int i,k;
for(i=0; i<n-1; i++)
{
for(k=i+1; k<n; k++)
{
if(a[i]>a[k])
{ //cout<<a[i]<<endl;
char temp;
temp=a[i];
a[i]=a[k];
a[k]=temp;
}
}
}
for(i=0; i<n; i++)
{
cout<<a[i];
}
cout<<endl;
}
}