Jump to content

Sort a list of object identifiers: Difference between revisions

→‎{{header|Perl 6}}: add shorter solution
m (added whitespace before the TOC (table of contents), added a ;Task: (bold) header.)
(→‎{{header|Perl 6}}: add shorter solution)
Line 506:
>;</lang>
 
Alternately, same output:
<lang Perl6>use Sort::Naturally;
 
.say for sort { .&naturally }, <
.1.3.6.1.4.1.11.2.17.19.3.4.0.10
.1.3.6.1.4.1.11150.3.4.0.2
.1.3.6.1.4.1.11.2.17.19.3.4.0.19
.1.3.6.1.4.1.11150.3.4.0.1
.1.3.6.1.4.1.11.2.17.19.3.4.0.22
.1.3.6.1.4.1.11.2.17.19.3.4.0.2
.1.3.6.1.4.1.11150.3.4.0.11
.1.3.6.1.4.1.11.2.17.19.3.4.0.1
.1.3.6.1.4.1.11.2.17.3773.0.2
.1.3.6.1.4.1.11.2.17.19.2.0.79
.1.3.6.1.4.1.11150.3.4.0.21
.1.3.6.1.4.1.11.2.17.19.2.0.9
.1.3.6.1.4.1.11.2.17.19.3.4.0.25
.1.3.6.1.4.1.11.2.17.19.3.4.0.32
.1.3.6.1.4.1.11.2.17.19.3.4.0.4
.1.3.6.1.4.1.11.2.17.19.3.4.0.31
.1.3.6.1.4.1.11.2.17.19.3.4.0.3
.1.3.6.1.4.1.11.2.17.3773.0.1
>;</lang>
{{out}}
<pre>.1.3.6.1.4.1.11.2.17.19.2.0.9
Line 548 ⟶ 525:
.1.3.6.1.4.1.11150.3.4.0.11
.1.3.6.1.4.1.11150.3.4.0.21</pre>
 
Alternatively, more golfed:
 
<lang Perl6>.say for sort *.split('.')».Int, <
...
>;</lang>
 
Or if using a third-party module is acceptable ''(input elided)'':
 
<lang Perl6>use Sort::Naturally;
 
.say for sort { .&naturally }, <
...
>;</lang>
 
=={{header|REXX}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.