Sort the letters of string in alphabetical order: Difference between revisions

Add Comal
(Add C++)
(Add Comal)
Line 304:
stream$putl(po, sort_string(str))
end start_up</lang>
{{out}}
<pre>Now is the time for all good men to come to the aid of their country.
.Naaccddeeeeeeffghhhiiiillmmmnnooooooooorrrstttttttuwy</pre>
 
=={{header|Comal}}==
<lang comal>0010 PROC strsort(REF s$) CLOSED
0020 DIM count#(0:255)
0030 FOR i#:=1 TO LEN(s$) DO count#(ORD(s$(i#))):+1
0040 i#:=1
0050 FOR j#:=0 TO 255 DO
0060 IF count#(j#)>0 THEN
0070 s$(i#:i#+count#(j#)-1):=CHR$(j#)*count#(j#)
0080 i#:+count#(j#)
0090 ENDIF
0100 ENDFOR j#
0110 ENDPROC strsort
0120 //
0130 test$:="Now is the time for all good men "
0140 test$:+"to come to the aid of their country."
0150 PRINT test$
0160 strsort(test$)
0170 PRINT test$
0180 END</lang>
{{out}}
<pre>Now is the time for all good men to come to the aid of their country.
2,093

edits