Largest int from concatenated ints: Difference between revisions

Content added Content deleted
Line 2,376: Line 2,376:


=={{header|Smalltalk}}==
=={{header|Smalltalk}}==
sort by padded print strings:
Version 1) sort by padded print strings:
{{works with|Smalltalk/X}}
{{works with|Smalltalk/X}}
<lang smalltalk>#(
<lang smalltalk>#(
Line 2,394: Line 2,394:
Stdout printCR: resultString.
Stdout printCR: resultString.
].</lang>
].</lang>
alternative: sort by concatenated pair's strings:
Version 2) alternative: sort by concatenated pair's strings:
<lang smalltalk>#(
<lang smalltalk>#(
(54 546 548 60)
(54 546 548 60)
Line 2,406: Line 2,406:
Stdout printCR: resultString.
Stdout printCR: resultString.
].</lang>
].</lang>
&sup1; replace e'{a}{b}' by (a printString,b printString) in dialects, which dp not support embedded expression strings.
Note &sup1; replace "e'{a}{b}'" by "(a printString,b printString)" in dialects, which do not support embedded expression strings.


no need to collect the resultString; simply print the sorted list (ok, if printing is all we want):
Version 3) no need to collect the resultString; simply print the sorted list (ok, if printing is all we want):
<lang smalltalk>#(
<lang smalltalk>#(
(54 546 548 60)
(54 546 548 60)
Line 2,417: Line 2,417:
Stdout cr.
Stdout cr.
]</lang>
]</lang>

no need to generate any intermediate strings; the following will do as well:
Version 4) no need to generate any intermediate strings; the following will do as well:
<lang smalltalk>#(
<lang smalltalk>#(
(54 546 548 60)
(54 546 548 60)