Sort a list of object identifiers: Difference between revisions

task description: make the test-case shorter, more useful (catches edge-cases), and accurate (Wikipedia article says nothing about a leading dot)
(Task description: Improve formatting, wording, and be explicit about the specification)
(task description: make the test-case shorter, more useful (catches edge-cases), and accurate (Wikipedia article says nothing about a leading dot))
Line 9:
{{task heading|Details}}
 
* An OID consists of one or more non-negative integers in base 10, separated by dots. It starts and ends with a number.
* Their natural sort order is [[wp:Lexicographical|lexicographical]] with regard to the dot-separated fields, using numeric comparison between fields.
 
Line 20:
|-
|
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.10</code><br>
<code>.1.3.6.1.4.1.1115011.32.417.05.2.0.79</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.194</code><br>
<code>.1.3.6.1.4.1.11150.3.4.0.1</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.221</code><br>
<code>.1.3.6.1.4.1.11.2.17.1911150.3.4.0.2</code><br>
<code>.1.3.6.1.4.1.11150.3.4.0.11</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.1</code><br>
<code>.1.3.6.1.4.1.11.2.17.3773.0.2</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.2.0.79</code><br>
<code>.1.3.6.1.4.1.11150.3.4.0.21</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.2.0.9</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.25</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.32</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.4</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.31</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.3</code><br>
<code>.1.3.6.1.4.1.11.2.17.3773.0.1</code><br>
|
<code>.1.3.6.1.4.1.11.2.17.19.23.4.0.91</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.23.4.0.794</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.110</code><br>
<code>.1.3.6.1.4.1.11.2.17.1911150.3.4.0.2</code><br>
<code>.1.3.6.1.4.1.11.2.17.1911150.3.4.0.31</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.4</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.10</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.19</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.22</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.25</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.31</code><br>
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.32</code><br>
<code>.1.3.6.1.4.1.11.2.17.3773.0.1</code><br>
<code>.1.3.6.1.4.1.11.2.17.3773.0.2</code><br>
<code>.1.3.6.1.4.1.11150.3.4.0.1</code><br>
<code>.1.3.6.1.4.1.11150.3.4.0.2</code><br>
<code>.1.3.6.1.4.1.11150.3.4.0.11</code><br>
<code>.1.3.6.1.4.1.11150.3.4.0.21</code><br>
|}
 
Line 66 ⟶ 41:
 
=={{header|C++}}==
 
{{update|C++|the format description and test-case in the task description have been updated}}
 
<lang Cpp>#include <string>
#include <vector>
Line 155 ⟶ 133:
</pre>
 
=={{header|Elixir}}==
 
{{update|Elixir|the format description and test-case in the task description have been updated}}
 
=={{header|Elixir}}==
{{works with|Elixir|1.3.1}}
<lang elixir>defmodule Sort_by_OID do
Line 216 ⟶ 195:
 
=={{header|Haskell}}==
 
{{update|Haskell|the format description and test-case in the task description have been updated}}
 
<lang Haskell>import Data.List ( sortBy , intercalate )
 
Line 288 ⟶ 270:
# 18 | .1.3.6.1.4.1.11150.3.4.0.21 |
</pre>
 
 
=={{header|J}}==
 
{{update|J|the format description and test-case in the task description have been updated}}
 
Data:
Line 344 ⟶ 327:
 
=={{header|Lua}}==
 
{{update|Lua|the format description and test-case in the task description have been updated}}
 
Using the in-built table.sort with a custom compare function.
<lang Lua>local OIDs = {
Line 399 ⟶ 385:
 
=={{header|Perl}}==
 
{{update|Perl|the format description and test-case in the task description have been updated}}
 
<lang perl>
Line 484 ⟶ 472:
 
</pre>
 
 
=={{header|Perl 6}}==
 
{{update|Perl 6|the format description and test-case in the task description have been updated}}
 
{{trans|Perl}}
<lang perl6>use v6;
Line 546 ⟶ 536:
 
=={{header|REXX}}==
 
{{update|REXX|the format description and test-case in the task description have been updated}}
 
This REXX version doesn't assume a leading decimal point.
<lang rexx>/*REXX program performs a sort of OID (Object IDentifiers ◄── used in Network data). */
Line 634 ⟶ 627:
 
=={{header|Ring}}==
 
{{update|Ring|the format description and test-case in the task description have been updated}}
 
<lang Ring>
 
Line 781 ⟶ 777:
 
=={{header|zkl}}==
 
{{update|zkl|the format description and test-case in the task description have been updated}}
 
Translation of http://rosettacode.org/wiki/Natural_sorting#zkl
 
Anonymous user