#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int cmp(const void *a, const void *b){
	const char *x = a;
	const char *y = b;
	char ix = tolower(*x);
	char iy = tolower(*y);
	if( ix > iy ) return 1;
	else if( ix < iy ) return -1;
	if(isupper((unsigned char)*x)) return -1;
	if(isupper((unsigned char)*y)) return  1;
	return 0;
}

int main(void){
	char letters[] = "baBadxD";

	printf("before: %s\n", letters);
	qsort(letters, sizeof(letters)-1, sizeof(*letters), cmp);
	printf("after : %s\n", letters);
	return 0;
}