Largest int from concatenated ints: Difference between revisions

Line 2,376:
 
=={{header|Smalltalk}}==
Version 1) sort by padded print strings:
{{works with|Smalltalk/X}}
<lang smalltalk>#(
Line 2,394:
Stdout printCR: resultString.
].</lang>
Version 2) alternative: sort by concatenated pair's strings:
<lang smalltalk>#(
(54 546 548 60)
Line 2,406:
Stdout printCR: resultString.
].</lang>
Note &sup1; replace "e'{a}{b}'" by "(a printString,b printString)" in dialects, which dpdo not support embedded expression strings.
 
Version 3) no need to collect the resultString; simply print the sorted list (ok, if printing is all we want):
<lang smalltalk>#(
(54 546 548 60)
Line 2,417:
Stdout cr.
]</lang>
 
Version 4) no need to generate any intermediate strings; the following will do as well:
<lang smalltalk>#(
(54 546 548 60)
Anonymous user