| 1 | Initialize gap | 5 | - | - | - | [23, 12, 1, 8, 34, 54, 2, 3, 7, 4] |
| 2 | i=5, temp=54 | 5 | 5 | 0 and 5 (23 vs 54) | No shift | [23, 12, 1, 8, 34, 54, 2, 3, 7, 4] |
| 3 | i=6, temp=2 | 5 | 6 | 1 and 6 (12 vs 2) | Shift 12 to index 6 | [23, 12, 1, 8, 34, 54, 12, 3, 7, 4] |
| 4 | j=1, compare 12 and 2 | 5 | 6 | No more shift | Place 2 at index 1 | [23, 2, 1, 8, 34, 54, 12, 3, 7, 4] |
| 5 | i=7, temp=3 | 5 | 7 | 2 and 7 (1 vs 3) | No shift | [23, 2, 1, 8, 34, 54, 12, 3, 7, 4] |
| 6 | i=8, temp=7 | 5 | 8 | 3 and 8 (8 vs 7) | Shift 8 to index 8 | [23, 2, 1, 8, 34, 54, 12, 3, 8, 4] |
| 7 | j=3, compare 8 and 7 | 5 | 8 | No more shift | Place 7 at index 3 | [23, 2, 1, 7, 34, 54, 12, 3, 8, 4] |
| 8 | i=9, temp=4 | 5 | 9 | 4 and 9 (34 vs 4) | Shift 34 to index 9 | [23, 2, 1, 7, 34, 54, 12, 3, 8, 34] |
| 9 | j=4, compare 34 and 4 | 5 | 9 | No more shift | Place 4 at index 4 | [23, 2, 1, 7, 4, 54, 12, 3, 8, 34] |
| 10 | Reduce gap | 2 | - | - | - | [23, 2, 1, 7, 4, 54, 12, 3, 8, 34] |
| 11 | i=2, temp=1 | 2 | 2 | 0 and 2 (23 vs 1) | Shift 23 to index 2 | [23, 2, 23, 7, 4, 54, 12, 3, 8, 34] |
| 12 | j=0, compare 23 and 1 | 2 | 2 | No more shift | Place 1 at index 0 | [1, 2, 23, 7, 4, 54, 12, 3, 8, 34] |
| 13 | i=3, temp=7 | 2 | 3 | 1 and 3 (2 vs 7) | No shift | [1, 2, 23, 7, 4, 54, 12, 3, 8, 34] |
| 14 | i=4, temp=4 | 2 | 4 | 2 and 4 (23 vs 4) | Shift 23 to index 4 | [1, 2, 23, 7, 23, 54, 12, 3, 8, 34] |
| 15 | j=2, compare 23 and 4 | 2 | 4 | No more shift | Place 4 at index 2 | [1, 2, 4, 7, 23, 54, 12, 3, 8, 34] |
| 16 | i=5, temp=54 | 2 | 5 | 3 and 5 (7 vs 54) | No shift | [1, 2, 4, 7, 23, 54, 12, 3, 8, 34] |
| 17 | i=6, temp=12 | 2 | 6 | 4 and 6 (23 vs 12) | Shift 23 to index 6 | [1, 2, 4, 7, 23, 54, 23, 3, 8, 34] |
| 18 | j=4, compare 23 and 12 | 2 | 6 | No more shift | Place 12 at index 4 | [1, 2, 4, 7, 12, 54, 23, 3, 8, 34] |
| 19 | i=7, temp=3 | 2 | 7 | 5 and 7 (54 vs 3) | Shift 54 to index 7 | [1, 2, 4, 7, 12, 54, 23, 54, 8, 34] |
| 20 | j=5, compare 54 and 3 | 2 | 7 | 3 and 5 (7 vs 3) | Shift 7 to index 5 | [1, 2, 4, 7, 12, 7, 23, 54, 8, 34] |
| 21 | j=3, compare 7 and 3 | 2 | 7 | No more shift | Place 3 at index 3 | [1, 2, 4, 3, 12, 7, 23, 54, 8, 34] |
| 22 | i=8, temp=8 | 2 | 8 | 6 and 8 (23 vs 8) | Shift 23 to index 8 | [1, 2, 4, 3, 12, 7, 23, 54, 23, 34] |
| 23 | j=6, compare 23 and 8 | 2 | 8 | 4 and 6 (12 vs 8) | Shift 12 to index 6 | [1, 2, 4, 3, 12, 7, 12, 54, 23, 34] |
| 24 | j=4, compare 12 and 8 | 2 | 8 | No more shift | Place 8 at index 4 | [1, 2, 4, 3, 8, 7, 12, 54, 23, 34] |
| 25 | i=9, temp=34 | 2 | 9 | 7 and 9 (54 vs 34) | Shift 54 to index 9 | [1, 2, 4, 3, 8, 7, 12, 54, 23, 54] |
| 26 | j=7, compare 54 and 34 | 2 | 9 | No more shift | Place 34 at index 7 | [1, 2, 4, 3, 8, 7, 12, 34, 23, 54] |
| 27 | Reduce gap | 1 | - | - | - | [1, 2, 4, 3, 8, 7, 12, 34, 23, 54] |
| 28 | i=1, temp=2 | 1 | 1 | 0 and 1 (1 vs 2) | No shift | [1, 2, 4, 3, 8, 7, 12, 34, 23, 54] |
| 29 | i=2, temp=4 | 1 | 2 | 1 and 2 (2 vs 4) | No shift | [1, 2, 4, 3, 8, 7, 12, 34, 23, 54] |
| 30 | i=3, temp=3 | 1 | 3 | 2 and 3 (4 vs 3) | Shift 4 to index 3 | [1, 2, 4, 4, 8, 7, 12, 34, 23, 54] |
| 31 | j=2, compare 4 and 3 | 1 | 3 | No more shift | Place 3 at index 2 | [1, 2, 3, 4, 8, 7, 12, 34, 23, 54] |
| 32 | i=4, temp=8 | 1 | 4 | 3 and 4 (4 vs 8) | No shift | [1, 2, 3, 4, 8, 7, 12, 34, 23, 54] |
| 33 | i=5, temp=7 | 1 | 5 | 4 and 5 (8 vs 7) | Shift 8 to index 5 | [1, 2, 3, 4, 8, 8, 12, 34, 23, 54] |
| 34 | j=4, compare 8 and 7 | 1 | 5 | No more shift | Place 7 at index 4 | [1, 2, 3, 4, 7, 8, 12, 34, 23, 54] |
| 35 | i=6, temp=12 | 1 | 6 | 5 and 6 (8 vs 12) | No shift | [1, 2, 3, 4, 7, 8, 12, 34, 23, 54] |
| 36 | i=7, temp=34 | 1 | 7 | 6 and 7 (12 vs 34) | No shift | [1, 2, 3, 4, 7, 8, 12, 34, 23, 54] |
| 37 | i=8, temp=23 | 1 | 8 | 7 and 8 (34 vs 23) | Shift 34 to index 8 | [1, 2, 3, 4, 7, 8, 12, 34, 34, 54] |
| 38 | j=7, compare 34 and 23 | 1 | 8 | No more shift | Place 23 at index 7 | [1, 2, 3, 4, 7, 8, 12, 23, 34, 54] |
| 39 | i=9, temp=54 | 1 | 9 | 8 and 9 (34 vs 54) | No shift | [1, 2, 3, 4, 7, 8, 12, 23, 34, 54] |
| 40 | gap=0, done | 0 | - | - | - | [1, 2, 3, 4, 7, 8, 12, 23, 34, 54] |