Sort a list of object identifiers: Difference between revisions

m (J: example has been updated)
Line 391:
=={{header|Perl 6}}==
 
The <tt>sort</tt> routine accepts a transformsort functionkey atcallback as the first argument,. whichHere we usegenerate herea tolist sortof each stringintegers as the listsort ofkey integersfor thateach itOID, represents.which (Lists of numbers are automaticallygets sorted lexicographically with numeric comparison by default.)
 
<lang perl6>.say for sort *.splitcomb('.'/\d+/)».Int, <
1.3.6.1.4.1.11.2.17.19.3.4.0.10
1.3.6.1.4.1.11.2.17.5.2.0.79
Line 412:
</pre>
 
Alternatively, using the <tt>sprintf</tt>-based approach used by the Perl solution, for comparison ''(input elided)'':
 
<lang perl6>.say for sort *.combsplit(/\d+/'.').fmt('%08d'), <...>;</lang>
 
Or if using a third-party module is acceptable:
Anonymous user