function quickSort( _arr ){
if( _arr.length <= 1 )
return _arr;
let pivotIndex = Math.floor( _arr.length / 2 );
let pivot = _arr.splice( pivotIndex, 1 )[0];
let left = [];
let right = [];
for( let i=0;i<_arr.length;i++ ){
if( _arr[i] <= pivot ){
left.push( _arr[i] )
} else {
right.push( _arr[i] )
}
}
return quickSort(left).concat( [pivot], quickSort(right));
}
var arr = [12,7,19, 55,10,21,45,13,25 ,8];
console.log( quickSort(arr) );