#include <stdio.h>

int comparator(char *stra,char *strb){
	int i;
	for(i=0;stra[i]!='\0' && strb[i]!='\0'; i++){
		if(stra[i]>strb[i]){
			return 1;
		}else if(stra[i]<strb[i]){
			return -1;
		}
	}
	if(stra[i]=='\0' && strb[i]=='\0'){return 0;}
	else if(strb[i]=='\0' ){return 1;}
	else { return -1;}
}


void sort(char **strarr, int len){
	int i,j;int res;int max;
	char *temporary;
	for(i=0;i<len;i++){
		max=i;
		for(j=i;j<len;j++){
			res=comparator(strarr[max],strarr[j]);
			if(res==1){ // only if bigger we change the max
				max=j;
			}
		}
		// exchange all 3 elements
		temporary=strarr[i];
		strarr[i]=strarr[max];
		strarr[max]=temporary;
	}
}


int main(int c,char **v){
	int i;
	char *array[3];
	array[0]="Ax";
	array[1]="Ar";
	array[2]="Aa";
	sort(array,3);
	for(i=0;i<3;i++){
		printf("%s\n",array[i]);
	}
}
