javascript - How can I move items within an array rather than use a new array? -


i have implemented quicksort algoritm in javascript. looks this

        function quicksort(array){           if (array.length <= 1) return array;             var less = [];             var more = [];             var equal = [];             var i;             var pivot = (array.length / 2) | 0;             for(i = 0; < array.length; i++) {               if (array[i] > array[pivot]) {                 more.push(array[i]);             } else if (array[i] < array[pivot]) {                 less.push(array[i]);               } else {                 equal.push(array[i]);               }             }             return quicksort(less).concat(equal, quicksort(more));         }         document.write(quicksort([3,46,78,90,48,32,13,6,45,87,32,56,45]));  

but want instead of pushing values in array different arrays have move values within array itself. how do that?


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -