function SortedStateChanges=Statelizer(state_INFO)
    k=1
    l=1
    
%%      
    
    for i=1:38
    t1=state_INFO(1,39-i).Target
    StateChanges(k,l)=state_INFO(1,39-i).DataIndex
    l=l+1
    if i==38;
    elseif state_INFO(1,38-i).Target==t1
        StateChanges(k,l)=state_INFO(1,39-i).DataIndex
    elseif state_INFO(1,38-i).Target ~= t1
        l=1
        k=k+1
         StateChanges(k,l)=state_INFO(1,39-i).DataIndex
    end
    end

    for i=1:12
        SortedStateChanges(i,:)=sort(StateChanges(i,:))
    end
    
    for i=1:12
       row=find(SortedStateChanges(i,:))
       for l=1:size(row,2)
       SChange(i,l)=SortedStateChanges(i,row(l))
       end
    end
    
    