Sorting algorithms/Insertion sort: Difference between revisions

Content added Content deleted
(→‎{{header|REXX}}: added/changed whitespace and comments.)
(→‎{{header|CMake}}: fixed loop index bug that caused function to fail for lists with one item)
Line 342: Line 342:
function(insertion_sort var)
function(insertion_sort var)
math(EXPR last "${ARGC} - 1") # Sort ARGV[1..last].
math(EXPR last "${ARGC} - 1") # Sort ARGV[1..last].
foreach(i RANGE 2 ${last})
foreach(i RANGE 1 ${last})
# Extend the sorted area to ARGV[1..i].
# Extend the sorted area to ARGV[1..i].
set(b ${i})
set(b ${i})