0

I'm looking to sort a list of IP addresses using VB script. I've looked for solutions in plenty of places so if this happens to be a duplicate, I welcome this being marked as one. I'm new to using VBS but the syntax is easy to understand so any working solution or guideline will do. It seems tricky enough to accomplish due to VB not having a committed sort function (or Sub), as well as IPs being easy to misinterpret. I havn't tried anything as such yet.

Example:

123.123.123.123,
12.12.1.12,
23.34.56.11,
45.33.22.1,
1.3.5.55,

to become

1.3.5.55,
12.12.1.12,
23.34.56.11,
45.33.22.1,
123.123.123.123
Alex K.
  • 171,639
  • 30
  • 264
  • 288
Oisín Foley
  • 2,317
  • 2
  • 22
  • 29

1 Answers1

0

By changing the test data to

Dim aTests : aTests = Array( _
  "123.123.123.123" _
, "12.12.1.12" _
, "23.34.56.11" _
, "45.33.22.1" _
, "1.3.5.55" _
)

and taking care of four elements in the format:

alVers.Add oFmt.formatArray("{0,4}.{1,4}.{2,4}.{3,4}", aParts)

the technique/code from here produced the output:

123.123.123.123
12.12.1.12
23.34.56.11
45.33.22.1
1.3.5.55
---------------
   1.   3.   5.  55
  12.  12.   1.  12
  23.  34.  56.  11
  45.  33.  22.   1
 123. 123. 123. 123
---------------
1.3.5.55
12.12.1.12
23.34.56.11
45.33.22.1
123.123.123.123
Community
  • 1
  • 1
Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96