var arr=[3,6,21,32,43,54,6,57,88,0,4,32,5,8,6];
async function qsort(array,left,right,resolve){
var i,j;
var pivot;
i=left;
j=right;
pivot=array[Math.floor((left+right)/2)];
var arr=[3,6,21,32,43,54,6,57,88,0,4,32,5,8,6];
async function qsort(array,left,right,resolve){
var i,j;
var pivot;
i=left;
j=right;
pivot=array[Math.floor((left+right)/2)];
while(1){
while(array[i]<pivot){
await new Promise((resolve)=>{setTimeout(()=>{resolve()},10)})
i++;
}
while(pivot<array[j]){
await new Promise((resolve)=>{setTimeout(()=>{resolve()},10)})
j--;
}
if(i>=j) break;
await new Promise((resolve)=>{setTimeout(()=>{resolve()},10)})
Swap(array,i,j);
i++;j--;
}
if(left<i-1){
qsort(array,left,i-1,resolve);
}
if(j+1<right){
qsort(array,j+1,right,resolve)
}
if(left>=i-1&&j+1>=right){return resolve();}
}
function Swap(array,i,j){
var temp=array[i];
array[i]=array[j];
array[j]=temp;
}
async function sortTest(){
await new Promise((resolve)=>{qsort(arr,0,arr.length-1,resolve);})//ソートが終わるまで待つ
console.log(arr)//ソート完了後のarrを表示したい
}
sortTest();
}
function Swap(array,i,j){
var temp=array[i];
array[i]=array[j];
array[j]=temp;
}
async function sortTest(){
await new Promise((resolve)=>{qsort(arr,0,arr.length-1,resolve);})//ソートが終わるまで待つ
console.log(arr)//ソート完了後のarrを表示したい
}
sortTest();