Sort by Length for OCaml Golf Competition by *yuko*

var s:array[0..999]of string;i,j:word;begin
repeat i:=i+1;readln(s[i]);for j:=1to i do if
chr(length(s[i]))+s[i]<chr(length(s[j]))+s[j]then
begin s[0]:=s[i];s[i]:=s[j];s[j]:=s[0]end
until eof;for i:=1to i do writeln(s[i])end.

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page