# Generated by tools/algo/legacy.py from the corpus: do not edit. # The /compare page's insertion sort on a copy. # Element comparisons are routed through lib/algo/legacy/order.viv; nothing else changes. from algo.legacy.order import lg_gt # from study/compare/lists/sorting.viv: insertion_sort def insertion_sort(a) { a = copy(a) for i from 1 to len(a) { v = a[i] j = i while j > 0 and lg_gt(a[j - 1], v) { a[j] = a[j - 1] j -= 1 } a[j] = v } return a }