#include<stdio.h>
#include <string.h>

const int MAX_LEN=200; /* Maximum length of an input string */

int main(int argc, char *argv[])
{
    char my_text[MAX_LEN]; /* Text to be input by the user */
	char tmp_text;		/* Used for swap */
	int i;
	int changed= 1;			// If set to 1 then change was made by sort
    fgets(my_text, MAX_LEN, stdin);
    printf ("Text entered was %s\n",my_text);
	while (changed) {  // Repeat until there are no changes
		changed= 0;
		/* loop over text to length of string */
		for (i= 1; i < strlen(my_text); i++){
			if (my_text[i-1] > my_text[i]) {
				tmp_text= my_text[i];  /* Swap characters */
				my_text[i]= my_text[i-1];
				my_text[i-1]= tmp_text;
				changed= 1;
			}
		}
	}
	printf ("Sorted text: %s\n",my_text);
    return 0;
}
