Sort a list of object identifiers: Difference between revisions
Content added Content deleted
(→{{header|Perl 6}}: add shorter solution) |
(Task description: Improve formatting, wording, and be explicit about the specification) |
||
Line 1: | Line 1: | ||
{{draft task}} |
{{draft task}} |
||
[[wp:Object identifier|Object identifiers (OID)]] are strings used to identify objects in network data. |
|||
;Task: |
|||
Sort by OID numbers. |
|||
{{task heading}} |
|||
OID - Object Identifiers are used in Network data' |
|||
<br>These numbers can vary in length, and have a dot "." between them. |
|||
<br>The individual number can be of different number of digits also. |
|||
Show how to sort a list of OIDs naturally. |
|||
{{task heading|Details}} |
|||
;Example: |
|||
<pre> |
|||
====================================== |
|||
INPUT |
|||
* An OID consists of one or more non-negative integers in base 10, separated by dots. |
|||
@arrayOID = |
|||
* Their natural sort order is [[wp:Lexicographical|lexicographical]] with regard to the dot-separated fields, using numeric comparison between fields. |
|||
( |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
); |
|||
{{task heading|Test case}} |
|||
======================================== |
|||
OUTPUT - Correctly Sorted |
|||
{| class="wikitable" |
|||
⚫ | |||
|- |
|||
⚫ | |||
! Input ''(list of strings)'' |
|||
⚫ | |||
! Output ''(list of strings)'' |
|||
⚫ | |||
|- |
|||
⚫ | |||
| |
|||
⚫ | |||
<code>.1.3.6.1.4.1.11.2.17.19.3.4.0.10</code><br> |
|||
<code>.1.3.6.1.4.1.11150.3.4.0.2</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.11150.3.4.0.1</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.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> |
|||
⚫ | |||
</pre> |
|||
⚫ | |||
<br><br> |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
| |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
|} |
|||
{{task heading|Related tasks}} |
|||
* [[Natural sorting]] |
|||
<hr> |
|||
=={{header|C++}}== |
=={{header|C++}}== |