Home >Web Front-end >JS Tutorial >JavaScript algorithm learning (direct insertion sorting)_javascript skills
1. Basic idea
Assume that the records to be sorted are stored in the array R[1..n]. Initially, R[1] forms an ordered area, and the unordered area is R[2..n]. From i=2 until i=n, R[i] is inserted into the current ordered area R[1..i-1] in sequence, generating an ordered area containing n records.