Sorting
Tools
General
Sister projects
In other projects
| Language | General Usage |
|---|---|
| Pseudocode | n ← MaxIndex - 1FOR i ← 1 TO n FOR j ← 1 TO nIF MyList[j] > MyList[j + 1]THENTemp ← MyList[j]MyList[j] ← MyList[j + 1]MyList[j + 1] ← TempENDIFENDFORn ← n - 1 // this means the next time round the inner loop, we don't // look at the values already in the correct positions.ENDFOR |
| VB.NET |
| Language | General Usage |
|---|---|
| Pseudocode | FOR Pointer ← 2 TO NumberOfitemsItemToBeInserted ← List[Pointer]CurrentItem ← Pointer - 1 // pointer to last item in sorted part of listWHILE (List[CurrentItem] > ItemToBeInserted) AND (CurrentItem > 0)List[CurrentItem + 1] ← List[CurrentItem] // move current item downCurrentItem ← CurrentItem - 1 // look at the item aboveEND WHILEList[CurrentItem + 1] ← ItemToBeInserted // insert itemENDFOR |
| VB.NET |