Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. const qSort = (arry) => {
  2. if (arry.length === 0) {
  3. return [];
  4. }
  5. let left = [], right =[], pivot = arry[0];
  6. for (let i=1; i< arry.length; i++) {
  7. if(arry[i] < pivot) {
  8. left.push(arry[i]);
  9. } else {
  10. right.push(arry[i]);
  11. }
  12. };
  13.  
  14. return [...qSort(left), pivot, ...qSort(right)];
  15. }
  16.  
  17. const g = qSort(["b", "l", "c", "a"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement