Anonymous user
Largest int from concatenated ints: Difference between revisions
Largest int from concatenated ints (view source)
Revision as of 22:01, 28 December 2020
, 3 years ago→{{header|Smalltalk}}
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 ¹ replace "e'{a}{b}'" by "(a printString,b printString)" in dialects, which
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)
|