insertion sort
1.0.0
หลังจากที่คุณโคลน repo นี้คุณต้องย้ายภายในไดเรกทอรี insertion-sort และเรียกใช้คำสั่ง
npm install
ในการเรียกใช้
npm installคุณต้องติดตั้ง node.js
const testArray : number = [ 2 , 5 , - 12 , 91 , 5 ] ;
insertionSort ( testArray , SortDirection . DESC ) ; [ - 12 , 2 , 5 , 5 , 91 ]วิธี การแทรก ใช้สอง parametrs:
ASC หรือ DESC (ASC เป็นตัวเลือกเริ่มต้น)ASC (จากน้อยไปมาก), Desc จากมากไปน้อย)
บนกราฟิกนี้คุณจะเห็นว่า การแทรก Algortihm ทำงานอย่างไร: