First of all, according to the contributing guideline the sort should be named stalinSort, but was sortComrades.
Then, in Kotlin sort sorts inplace, while sorted returns a new list. So I've made 2 other implementations that follow this convention.
A minor improvement of the exisinting implementation: index is not ractually required, since previous is guaranteed to be not null.
Last but not least: some tests.
First of all, according to the contributing guideline the sort should be named
stalinSort
, but wassortComrades
.Then, in Kotlin
sort
sorts inplace, whilesorted
returns a new list. So I've made 2 other implementations that follow this convention.A minor improvement of the exisinting implementation: index is not ractually required, since
previous
is guaranteed to be not null.Last but not least: some tests.