Sort a list of object identifiers: Difference between revisions

jq
(→‎{{header|REXX}}: made more idiomatic by using a subroutine for generating the array, added/changed comments and whitespace, allowed for a larger identifier.)
(jq)
Line 380:
readInt :: String -> Int
readInt x = read x :: Int</lang>
 
=={{header|jq}}==
<lang jq>def data: [
"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",
"1.3.6.1.4.1.11.2.17.19.3.4.0.4",
"1.3.6.1.4.1.11150.3.4.0.1",
"1.3.6.1.4.1.11.2.17.19.3.4.0.1",
"1.3.6.1.4.1.11150.3.4.0"
];
 
data | map( split(".") | map(tonumber) ) | sort | map(join("."))</lang>
 
{{out}}
<pre>[
"1.3.6.1.4.1.11.2.17.5.2.0.79",
"1.3.6.1.4.1.11.2.17.19.3.4.0.1",
"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.10",
"1.3.6.1.4.1.11150.3.4.0",
"1.3.6.1.4.1.11150.3.4.0.1"
]</pre>
 
=={{header|J}}==
2,489

edits