title: How can I sorting the values in the jumping columns?
body: <p>I have a matrices 25x600 and some columns contains positive and negative values. I want the output like this [+ + - -] (four values 2 positive and 2 negative). I am guaranteed to always have two positive values immediately before the transition and two negative values immediately after. my attempting was as follow :</p>
  
  <p>My attempt was as follows:</p>
  
  <pre><code>    clc;
      clear all;
      close all;
      %%
      data=[-0.0059972;-0.004994;-0.0029881;2.0868e-05;
  0.0030299;0.013059;0.033115;0.063196;0.093273;0.1935;0.39385;0.69423;0.99448;1.9950;3.99550;6.99550;9.9957;19.9961;39.99620;69.9960;
  99.99530;199.99810;399.99140;699.98860;1000.03130]
      for r=1:600
          lam=data(:,r);
          N_lam = length(lam);
          %%
          for j=1:N_lam
              kk=0;
              r1=0;
              if(sign(lam(j))==1)
                  kk=kk+1;
                  lampos(kk)=lam(j);
                  if (length(lampos(kk))&gt;3 &amp;length(lamneg(r1))&gt;2)
                   break
                  end
              else
                  r1=r1+1;
                  lamneg(r1)=lam(j);
              end
          end
          cc{r}=[lampos lamneg];
      end
  </code></pre>
  
  <p>Any help would be greatly appreciated.</p>