Sorting algorithms/Gnome sort: Difference between revisions

Content added Content deleted
(Added Kotlin)
(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 1,286: Line 1,286:
var j = 2
var j = 2
while (i < a.size)
while (i < a.size)
if (ascending && (a[i - 1] <= a[i]) ||
if (ascending && (a[i - 1] <= a[i]) ||
!ascending && (a[i - 1] >= a[i]))
!ascending && (a[i - 1] >= a[i]))
i = j++
i = j++
else {
else {