Sorting algorithms/Insertion sort: Difference between revisions

m
imported>Arakov
m (→‎{{header|Wren}}: Minor tidy)
Line 5,215:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">var insertionSort = Fn.new { |a|
for (i in 1..a.count-1) {
var v = a[i]
Line 5,227:
}
 
var asarray = [ [4, 65, 2, -31, 0, 99, 2, 83, 782, 1], [7, 5, 2, 6, 1, 4, 2, 6, 3] ]
for (a in asarray) {
System.print("Before: %(a)")
insertionSort.call(a)
Line 5,246:
Alternatively we can just call a library method.
{{libheader|Wren-sort}}
<syntaxhighlight lang="ecmascriptwren">import "./sort" for Sort
 
var asarray = [ [4, 65, 2, -31, 0, 99, 2, 83, 782, 1], [7, 5, 2, 6, 1, 4, 2, 6, 3] ]
for (a in asarray) {
System.print("Before: %(a)")
Sort.insertion(a)
9,476

edits