Sorting algorithms/Insertion sort: Difference between revisions

+Stata
m (→‎{{header|Fortran}}: classic mistake with non-short-circuit logical operators)
(+Stata)
Line 2,779:
while output = A<i>; i = ?lt(i,aSize) i + 1 :s(while)
end</lang>
=={{header|Stata}}==
<lang stata>mata
void insertion_sort(real vector a) {
real scalar i, j, n, x
n = length(a)
for (i=2; i<=n; i++) {
x = a[i]
for (j=i-1; j>=1; j--) {
if (a[j] <= x) break
a[j+1] = a[j]
}
a[j+1] = x
}
}
end</lang>
 
=={{header|Swift}}==
Using generics.
1,336

edits