Sort a string internally with Perl
The following code sorts a given string internally in order of the characters’ ASCII values.
print sort split '', <STDIN>
A per-line analysis of the code wouldn’t say very much. This is the code with brackets added:
print( sort( split( '', <STDIN>) ) )
First, the input (<STDIN>) is split into an array with split. The first argument, '', means that it splits every character. sort sorts it in ASCII order, and the result is finally printed. The only flaw is that the linebreak (ASCII 10) is put first, and so you see a double linebreak between the input and the output.
