char * sortString(char * s){ int hash[26]={0}; int len = strlen(s); int i,pst=0; for (i=0; i<len; i++) hash[s[i] - 'a']++; while(pst < len) { for (i=0; i<26; i++) { if (hash[i]) { s[pst++]=i+'a'; hash[i]--; } } for (i=25; i>=0; i--) { if (hash[i]) { s[pst++]=i+'a'; hash[i]--; } } } return s; }