fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4.  
  5. int cmp(const void *a, const void *b){
  6. const char *x = a;
  7. const char *y = b;
  8. char ix = tolower(*x);
  9. char iy = tolower(*y);
  10. if( ix > iy ) return 1;
  11. else if( ix < iy ) return -1;
  12. if(isupper((unsigned char)*x)) return -1;
  13. if(isupper((unsigned char)*y)) return 1;
  14. return 0;
  15. }
  16.  
  17. int main(void){
  18. char letters[] = "baBadxD";
  19.  
  20. printf("before: %s\n", letters);
  21. qsort(letters, sizeof(letters)-1, sizeof(*letters), cmp);
  22. printf("after : %s\n", letters);
  23. return 0;
  24. }
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
before: baBadxD
after : aaBbDdx