Simply by using recursion instead of loops. <s>This particular version only works on characters between '0' and 'z', but that's just to keep the stack from overflowing too often.</s> Supporting all of ASCII.

    #include <stdio.h>
    void walk(char *s, char m){
        if (*s == '\0') return;
        if (*s == m) putchar(m);
    void sort(char *s, char m){
      if (m<127) sort(s,m+1);
    int main(int argc, char**argv){
      if (argc > 1) {
        printf("%s: ",argv[1]);

Sample run:

    $ ./a.out  thingamabob
    thingamabob: aabbghimnot
    $ ./a.out  supercalifragilisticexpalodoucious
    supercalifragilisticexpalodoucious: aaacccdeefgiiiiilllooopprrssstuuux
    $ ./a.out  "The quick red fox jumped over the lazy brown dog"
    The quick red fox jumped over the lazy brown dog:          Tabcdddeeeeefghhijklmnoooopqrrrtuuvwxyz

Too easy, really.