reorder text wave by alphabetic order
chrisNell
It may be a basic question but I didn't know who to reorder my text wave by alphabetic order.
I have a wave like:
Make/T/ w
w[0] = DA10_elecCal_2
w[1] = DA10_elecCal_3
w[2] = DA11_elecCal_2
w[3] = DA11_elecCal_3
w[4] = DA10_CurrentCal_2
w[5] = DA10_CurrentCal_3
w[6] = DA11_CurrentCal_2
w[7] = DA11_CurrentCal_3
and I want
w[0] = DA10_CurrentCal_2
w[1] = DA10_CurrentCal_3
w[2] = DA10_elecCal_2
w[3] = DA10_elecCal_3
w[4] = DA11_CurrentCal_2
w[5] = DA11_CurrentCal_3
w[6] = DA11_elecCal_2
w[7] = DA11_elecCal_3
Thanks
Make/T/N=8 w
w[0] = "DA10_elecCal_2"
w[1] ="DA10_elecCal_3"
w[2] = "DA11_elecCal_2"
w[3] = "DA11_elecCal_3"
w[4] = "DA10_CurrentCal_2"
w[5] = "DA10_CurrentCal_3"
w[6] = "DA11_CurrentCal_2"
w[7] = "DA11_CurrentCal_3"
sort w w
End
HTH,
Kurt
September 4, 2015 at 06:02 am - Permalink
September 4, 2015 at 06:44 am - Permalink
w[0] = DA10_elecCal_ch2_1001
w[1] = DA10_elecCal_ch3_1001
w[2] = DA10_elecCal_ch2_1002
w[3] = DA10_elecCal_ch3_1002
w[4] = DA10_elecCal_ch2_1003
w[5] = DA10_elecCal_ch3_1003
w[6] = DA11_elecCal_ch2_1001
w[7] = DA11_elecCal_ch3_1001
w[8] = DA10_CurrentCal_ch2_1001
w[9] = DA10_CurrentCal_ch3_1001
w[10] = DA11_CurrentCal_ch2_1001
w[11] = DA11_CurrentCal_ch3_1001
and I need
w[0] = DA10_CurrentCal_ch2_1001
w[1] = DA10_CurrentCal_ch3_1001
w[2] = DA10_elecCal_ch2_1001
w[3] = DA10_elecCal_ch3_1001
w[4] = DA10_elecCal_ch2_1002
w[5] = DA10_elecCal_ch3_1002
w[6] = DA10_elecCal_ch2_1003
w[7] = DA10_elecCal_ch3_1003
w[8] = DA11_CurrentCal_ch2_1001
w[9] = DA11_CurrentCal_ch3_1001
w[10] = DA11_elecCal_ch2_1001
w[11] = DA11_elecCal_ch3_1001
I was wondering if I can sort it only according to the first part of the name?
if you have any idea, thank you very much
September 4, 2015 at 08:17 am - Permalink
Make/O/N=12/T w
w[0] = "DA10_elecCal_ch2_1001"
w[1] = "DA10_elecCal_ch3_1001"
w[2] = "DA10_elecCal_ch2_1002"
w[3] = "DA10_elecCal_ch3_1002"
w[4] = "DA10_elecCal_ch2_1003"
w[5] = "DA10_elecCal_ch3_1003"
w[6] = "DA11_elecCal_ch2_1001"
w[7] = "DA11_elecCal_ch3_1001"
w[8] = "DA10_CurrentCal_ch2_1001"
w[9] = "DA10_CurrentCal_ch3_1001"
w[10] = "DA11_CurrentCal_ch2_1001"
w[11] = "DA11_CurrentCal_ch3_1001"
Make/O/N=(12)/T w0, w1, w2, w3
variable i
string s0, s1, s2, s3
for(i=0; i<12; i+=1)
sscanf w[i], "%[^_]_%[^_]_%[^_]_%[^_]", s0, s1, s2, s3
w0[i] = s0
w1[i] = s1
w2[i] = s2
w3[i] = s3
endfor
Sort {w0, w3, w1, w2}, w
End
September 4, 2015 at 09:19 am - Permalink
September 7, 2015 at 04:25 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
September 8, 2015 at 10:39 am - Permalink