Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9224949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:27:22+00:00 2026-06-18T04:27:22+00:00

I’m trying to sort lines in a file using VBScript (MS Internet Explorer). Basically

  • 0

I’m trying to sort lines in a file using VBScript (MS Internet Explorer). Basically I read the file and converted all the lines to an array. Basically I need to sort on whatever is written between character 23 and 27 of each line. So basically I can get those characters using MID. These characters are not unique per line (so I can’t use System.Collections.Sortedlist directly, or something similar unfortunately).

I may be able to use System.Collections.Sortedlist and use the characters between 23 and 27 as a key and use an other System.Collections.Sortedlist object as a value, filled with every unique value (so a 2-dimensional array), but will this be the right way? e.g.:

(System.Collections.Sortedlist) {
    "0001" => (System.Collections.Sortedlist) {
        0 => "0001 some unique value1"
        1 => "0001 some unique value2"
        2 => "0001 some unique value3"
    },
    "0002" => (System.Collections.Sortedlist) {
        0 => "0002 some unique value1"
        1 => "0002 some unique value2"
        2 => "0002 some unique value3"
    }
}

Is there a better way to handle this?
Also note the output format should be an array again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:27:24+00:00Added an answer on June 18, 2026 at 4:27 am

    As teaser (see also ArrayList, Disconnected Recordset and ArrayList ):

      Dim aTest : aTest = Array( _
          ". Z 0" _
        , ", B 2" _
        , "? A 1" _
      )
      WScript.Echo "----- ArrayList"
      WScript.Echo "original data:     ", "[""" & Join(aTest                          , """  """) & """]"
      WScript.Echo "AL:  (full)        ", "[""" & Join(sortAL(aTest)                  , """  """) & """]"
      WScript.Echo "AL:  (numerical)   ", "[""" & Join(sortAL(Array(12, 9, -1))       , """  """) & """]"
      WScript.Echo "AL:  (dates)       ", "[""" & Join(sortAL(Array(Now + 5, Now - 5)), """  """) & """]"
      WScript.Echo "AL:  (Mid(elm,3,1))", "[""" & Join(sortAL_31(aTest)               , """  """) & """]"
      WScript.Echo "----- Disconnected Recordset"
      WScript.Echo "DRS: (Mid(elm,3,1))", "[""" & Join(sortDRS_Substring(aTest, 3, 1) , """  """) & """]"
      WScript.Echo "DRS: (Mid(elm,5,1))", "[""" & Join(sortDRS_Substring(aTest, 5, 1) , """  """) & """]"
    
    ' ArrayList.Sort handles homogenous arrays of simple types just fine,
    ' but looks at the element in full. For other cases, you need extra work
    ' or ADO
    Function sortAL(aX)
      Dim al : Set al = CreateObject("System.Collections.ArrayList")
      Dim elm
      For Each elm In aX
          al.Add elm
      Next
      al.Sort
      sortAL = al.ToArray()
    End Function
    
    ' Extra work: feeding pre-processed data to the ArrayList; hardcoded
    Function sortAL_31(aX)
      Const csSep = ":"
      Dim al : Set al = CreateObject("System.Collections.ArrayList")
      ReDim a(UBound(aX))
      Dim elm
      For Each elm In aX
          al.Add Mid(elm, 3, 1) & csSep & elm
      Next
      al.Sort
      For elm = 0 To UBound(a)
          a(elm) = Split(al(elm), csSep)(1)
      Next
      sortAL_31 = a
    End Function
    
    ' more flexible: ADO DRS + a start at parametrization; handling different
    ' types is left as an exercise
    Function sortDRS_Substring(aX, nFrom, nLen)
      Const adVarChar    = 200 ' 000000C8
      Const adClipString =   2 ' 00000002
      Const csSep        = ":"
      ReDim a(Ubound(aX))
      Dim oRS : Set oRS = CreateObject("ADODB.Recordset")
      oRS.Fields.Append "FORG", adVarChar, 250
      oRS.Fields.Append "FSUB", adVarChar, 250
      oRS.Open
      Dim elm
      For Each elm In aX
          oRS.AddNew
          oRS.Fields("FORG").value = elm
          oRS.Fields("FSUB").value = Mid(elm, nFrom, nLen)
          oRS.UpDate
      Next
      oRS.Sort = "FSUB"
      oRS.MoveFirst
      For elm = 0 To UBound(a)
          a(elm) = oRS.Fields("FORG").value
          oRS.MoveNext
      Next
      sortDRS_Substring = a
    End Function
    

    output:

    ----- ArrayList
    original data:      [". Z 0"  ", B 2"  "? A 1"]
    AL:  (full)         [", B 2"  ". Z 0"  "? A 1"]
    AL:  (numerical)    ["-1"  "9"  "12"]
    AL:  (dates)        ["1/23/2013 5:00:22 PM"  "2/2/2013 5:00:22 PM"]
    AL:  (Mid(elm,3,1)) ["? A 1"  ", B 2"  ". Z 0"]
    ----- Disconnected Recordset
    DRS: (Mid(elm,3,1)) ["? A 1"  ", B 2"  ". Z 0"]
    DRS: (Mid(elm,5,1)) [". Z 0"  "? A 1"  ", B 2"]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
Basically, what I'm trying to create is a page of div tags, each has
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have thousands of HTML files to process using Groovy/Java and I need to
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.