/*******************************************************************

        String Sort: Sorts a string from <STDIN> to <STDOUT>
                              M. Leo Cooper
                                11-13-97

*******************************************************************/



#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAXLEN 80
#define CMDLINEARGS 2
#define INPUTERR 2
#define CR "\n"

int Sort( const void *first, const void *second );

int main( int argc, char **argv )
{
   char array[MAXLEN];
   int index,
       arraylen;


      if( argc != CMDLINEARGS )
          {
          printf( "\nform: stringsort STRING\n" );
          exit( INPUTERR );
          }


      strcpy( array, *( argv + 1 ) );
      arraylen = strlen( array );

      qsort( (void *)array, arraylen, sizeof( *array ), Sort );

      for( index = 0; index < arraylen; index++ )
         printf( "%c", array[index] );


      printf( CR );

      return( 0 );

}




int Sort( const void *s1, const void *s2 )
{
      return( strcmp( s1, s2 ) );
}
