DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Sort groups before concatenation

Solved!
Go to solution

Hello guys.

 

During our tests we record the data mostly in blocks, and concatenate them later.

Before this concatenation, the order of the loaded files should be checked/corrected.

In several topics here the bubble sorting is mentioned; in my case the result doesn't solve the problem:

 

Dia791_0-1658745237592.png

This is the result of such bubble sorting (not all groups are listed here, just few to show the problem).

The first block has no "_index" suffix (this is correct and comes in this way out of our data recording).

But then indices goes according the numbers, and this is not exactly correct.

 

The only one way I see is to load all files, adjust the group names (i.e. number of digits) and sort then.

Means, go through all groups, and change "_index2" to "_index_02" etc.

Check, if "_index100" exists; because then I need 3 digits...

Logically clear, but I'm awared about the possible mistakes.

 

Does anybody have a similar issue, and solved it in a different way?

 

Thanks,

Vassili

 

0 Kudos
Message 1 of 3
(1,315 Views)
Solution
Accepted by topic author Dia791

The easiest way would be to create the indices with leading zeros, so instead of index1, you have index001.  This is the easiest since text sorts are alphabetic.  

 

Here is a simple example that adds leading zeros. 

Option Explicit  'Forces the explicit declaration of all the variables in a script.
dim sString
sString = "-0101-7391-11_index1"
msgbox(AddLeadingZero(sString))


function AddLeadingZero(MyString)
  Dim SplitString, indexnumber
  SplitString = Split(MyString,"index",-1,vbtextcompare)
  indexnumber = Cint(SplitString(Ubound(SplitString)))
  AddLeadingZero = SplitString(0) & "index" & str(indexnumber,"0ddd")
end function
0 Kudos
Message 2 of 3
(1,285 Views)

Thanks, interesting function!

 

Needed to modify the last line slightly; otherwise my Diadem doesn't understand the format "0ddd":

  AddLeadingZero = SplitString(0) & "index" & REPLACE(str(indexnumber,"dddd"), " ", "0")

 

I did it in much more complicated way.

Thank you for improvement!

0 Kudos
Message 3 of 3
(1,275 Views)