Sort a list of object identifiers: Difference between revisions
→{{header|Phix}}
(Add Common Lisp implementation) |
|||
Line 426:
.say for sort &naturally, <...>;</lang>
=={{header|Phix}}==
I would normally recommend a tagsort, but we can avoid the extra routine and tagset here.
<lang Phix>sequence strings = {"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"}
constant len = length(strings)
sequence sortable = repeat(0,len)
for i=1 to len do
sequence si = split(strings[i],'.')
for j=1 to length(si) do
si[j] = to_number(si[j])
end for
sortable[i] = {si,i}
end for
sortable = sort(sortable)
for i=1 to len do
?strings[sortable[i][2]]
end for</lang>
<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|Python}}==
|