Presort array by Jongsic

while(q=readline()){i=a=0;v=[];for(r=eval(q);r[++i]>=0;)r[i]<r[i-1]&&(v.push(r.slice(a,i)),a=i);v.push(r.slice(a));v=v.sort(function(b,c){for(j=0;b[j]>=0&&c[j]>=0;j++)if(b[j]!=c[j])return b[j]-c[j];return b[j]||-1});print("["+v.join()+"]");}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page