Posted By

mouseit101 on 07/14/07


Tagged

actionscript sorting quicksort


Versions (?)

Quicksort


 / Published in: ActionScript
 

  1. function qsort(a){
  2. if (a.length <= 1){return a;}
  3. var p = a[0];
  4. var gr = [];
  5. var ls = [];
  6. for(i=1;i<a.length;i++){
  7. if (a[i] < p){ls.push(a[i]);}
  8. else{gr.push(a[i]);}
  9. }
  10. ls = qsort(ls);
  11. gr = qsort(gr);
  12. ls.push(p)
  13. return ls.concat(gr);
  14. }

Report this snippet  

You need to login to post a comment.