How to resolve the algorithm Sort a list of object identifiers step by step in the Wren programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sort a list of object identifiers step by step in the Wren programming language
Table of Contents
Problem Statement
Object identifiers (OID) are strings used to identify objects in network data.
Show how to sort a list of OIDs, in their natural sort order.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sort a list of object identifiers step by step in the Wren programming language
Source code in the wren programming language
import "/fmt" for Fmt
import "/sort" for Sort
var oids = [
"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"
]
oids = oids.map { |oid| Fmt.v("s", 5, oid.split("."), 0, ".", "") }.toList
Sort.quick(oids)
oids = oids.map { |oid| oid.replace(" ", "") }.toList
System.print(oids.join("\n"))
You may also check:How to resolve the algorithm Boolean values step by step in the Octave programming language
You may also check:How to resolve the algorithm Probabilistic choice step by step in the jq programming language
You may also check:How to resolve the algorithm Singly-linked list/Element definition step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Inheritance/Multiple step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Catamorphism step by step in the Icon and Unicon programming language