Anonymous user
Sorting algorithms/Insertion sort: Difference between revisions
→Insertion sort with binary search: added back deleted info, it's only a few lines so there's no harm
(→{{header|C}}: useless var) |
(→Insertion sort with binary search: added back deleted info, it's only a few lines so there's no harm) |
||
Line 1,255:
# insert key at position ``low``
seq[:] = seq[:low] + [key] + seq[low:i] + seq[i + 1:]</lang>
This is also built-in to the standard library:
<lang python>
import bisect
def insertion_sort_bin(seq):
for i in range(1, len(seq)):
bisect.insort(seq, seq.pop(i), 0, i)</lang>
=={{header|R}}==
Direct translation of pseudocode.
|