Sorting and plotting waves from lists

I have waves that have four general formats:
IOC_freq_Cell_05_20161221_s
IOC_freq_Cell_27_20161215_c
IOC_curr_Cell_23_20161215_c
IOC_curr_Cell_07_20161222_s


I would like to plot the IOC_freq_s waves vs IOC_curr_s and the IOC_freq_c vs IOC_curr_c

I have written a procedure where I can plot the waves one at a time but here is where I need help:

1. It doesn't seem to be sorting properly
2. Is there a way to actually have just two graphs as I mentioned above

THanks

function show2()

string current_list
string cell_list
string current_name
string cell_name
variable i
string new_curr
string new_cell



SetDataFolder root:
current_list = WaveList("IOC_curr*",";","")  //get wavelist matching current
cell_list = WaveList("IOC_freq*",";","")  //get wavelist matching current

for(i =0;i < itemsinlist(current_list);i +=1)
        current_name = stringfromlist(i,current_list)
        endfor
       
        new_curr = sortlist (current_list,";",4)
       

for(i =0;i < itemsinlist(cell_list);i +=1)
        cell_name = stringfromlist(i,cell_list)
       
        endfor
       
        new_cell = sortlist (cell_list,";",4)
       
       
for(i =0;i < itemsinlist(cell_list);i +=1)
display $(stringfromlist(i,new_cell, ";")) vs $(stringfromlist(i, new_curr, ";"))
endfor


end
 
1- The loops don't appear to do anything
2- How do the lists sort, and what did you expect? Can you give an example unsorted list and the resulting sorted list?

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
I managed to fix the sorting problem-- it was a mistake on my part.
I'd like to avoid plotting one by one though altogether if possible and just have two graphs in the end-- one with the s and one with the c suffix as I mentioned previously.

I am now getting all the waves in one plot by executing:

do
       
    appendtograph $(stringfromlist(i+1,new_cell, ";")) vs $(stringfromlist(i+1, new_curr, ";"))
    i+=1               
    while (i < itemsinlist(new_cell))
Here's some almost-code:
Display
String g1name = S_name
Display
String g2name = S_name
Variable i
Variable niters = ItemsInList(something)
for (i = 0; i < niters; i++)
    AppendToGraph/W=$g1name somewave
    AppendToGraph/W=$g2name someotherwave
endfor

This makes two blank graph windows and saves their names for later. The loop is clearly not going to work until you provide some more code, and it uses Igor 7-style index increment, but it should show you the technique. Pretty much all Igor commands that work on windows take a /W=<window name> flag. When writing functions it is good to get into the habit of always using the /W flag, even when you aren't trying to work on multiple windows. It can save a lot of heartache caused by bad results when a window unexpectedly becomes inactive.

John Weeks
WaveMetrics, Inc.
support@wavemetrics.com