Repository: MarkusAmshove/Kluent (kotlin)

Issue:
Sorted Collections assertion
It would be great to have an assertion which can check if the Collection is already sorted. The assertion would also accept a `Comparator` instance to verify with. Similar (or same) as [AssertJ](http://javadox.com/org.assertj/assertj-core/3.1.0/org/assertj/core/api/AbstractListAssert.html#isSortedAccordingTo-java.util.Comparator-)

It would be something along these lines:
```
list shouldBeSortedAccordingTo Comparator.comparingInt { it.position }
```
or
```
list shouldBeSortedBy Comparator.comparingInt { it.position }
```

This could then be chained to a structure like this
```
list.shouldNotBeEmpty()
.shouldHaveSize(10)
.shouldBeSortedAccordingTo(Comparator.comparing<Slot, Int> { it.position })
```

Pull request description:
Description
Implement Sorted Collections assertions on all collection types

Checklist
- [x] I've added my name to the `AUTHORS` file, if it wasn't already present.

Fix #167

Patch:
diff --git a/AUTHORS.md b/AUTHORS.md
index 0df8be0c..58443a45 100644
--- a/AUTHORS.md
+++ b/AUTHORS.md
@@ -36,3 +36,4 @@
 1. Yang C - [@ychescale9](https://github.com/ychescale9) ([Contributions](https://github.com/MarkusAmshove/Kluent/commits?author=ychescale9))
 1. Christian Ivicevic - [@ChristianIvicevic](https://github.com/ChristianIvicevic) ([Contributions](https://github.com/MarkusAmshove/Kluent/commits?author=ChristianIvicevic))
 1. Ivan Mikhnovich - [@Murtaught](https://github.com/Murtaught) ([Contributions](https://github.com/MarkusAmshove/Kluent/commits?author=Murtaught))
+1. Jc Miñarro - [@JcMinarro](https://github.com/JcMinarro) ([Contributions](https://github.com/MarkusAmshove/Kluent/commits?author=JcMinarro))
diff --git a/common/src/main/kotlin/org/amshove/kluent/Collections.kt b/common/src/main/kotlin/org/amshove/kluent/Collections.kt
index fc8e8798..9fdb5676 100644
--- a/common/src/main/kotlin/org/amshove/kluent/Collections.kt
+++ b/common/src/main/kotlin/org/amshove/kluent/Collections.kt
@@ -48,11 +48,26 @@ infix fun <T> Array<T>.shouldMatchAtLeastOneOf(predicate: (T) -> Boolean) = appl
 
 infix fun <T> Array<T>.shouldMatchAllWith(predicate: (T) -> Boolean) = apply { this.toList().shouldMatchAllWith(predicate) }
 
+infix fun <T> Array<T>.shouldBeSortedAccordingTo(comparator: Comparator<T>) = apply {
+    var index = 0
+    toList().zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("Array is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nArray was:\n <$this>")
+        index++
+    }
+}
 
 infix fun IntArray.shouldEqual(expected: IntArray) = apply { assertArrayEquals(this.toTypedArray(), expected.toTypedArray()) }
 
 infix fun IntArray.shouldNotEqual(expected: IntArray) = apply { assertArrayNotEquals(expected.toTypedArray(), this.toTypedArray()) }
 
+infix fun IntArray.shouldBeSortedAccordingTo(comparator: Comparator<Int>) = apply {
+    var index = 0
+    toList().zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("IntArray is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nIntArray was:\n <$this>")
+        index++
+    }
+}
+
 fun IntArray.shouldHaveSingleItem() = toList().shouldHaveSingleItem()
 
 fun IntArray.shouldBeEmpty() = apply { this.toTypedArray().shouldBeEmpty() }
@@ -119,6 +134,14 @@ fun BooleanArray.shouldContainTrue() = apply { this.toTypedArray().shouldContain
 
 fun BooleanArray.shouldContainFalse() = apply { this.toTypedArray().shouldContainAny { !it } }
 
+infix fun BooleanArray.shouldBeSortedAccordingTo(comparator: Comparator<Boolean>) = apply {
+    var index = 0
+    toList().zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("BooleanArray is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nBooleanArray was:\n <$this>")
+        index++
+    }
+}
+
 @Deprecated("Use shouldContainAny", ReplaceWith("this.shouldContainAny(check)"))
 infix fun BooleanArray.shouldContainSome(expected: Iterable<Boolean>) = apply { this.toList().shouldContainSome(expected) }
 
@@ -188,6 +211,14 @@ infix fun ByteArray.shouldNotContainAny(expected: ByteArray) = apply { expected.
 
 infix fun ByteArray.shouldNotContainAny(expected: Iterable<Byte>) = apply { this.toList().shouldNotContainAny(expected) }
 
+infix fun ByteArray.shouldBeSortedAccordingTo(comparator: Comparator<Byte>) = apply {
+    var index = 0
+    toList().zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("ByteArray is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nByteArray was:\n <$this>")
+        index++
+    }
+}
+
 infix fun Byte.shouldBeIn(theArray: ByteArray) = apply { this shouldBeIn theArray.toTypedArray() }
 
 infix fun Byte.shouldNotBeIn(theArray: ByteArray) = apply { this shouldNotBeIn theArray.toTypedArray() }
@@ -236,6 +267,14 @@ infix fun CharArray.shouldNotContainAny(expected: CharArray) = apply { expected.
 
 infix fun CharArray.shouldNotContainAny(expected: Iterable<Char>) = apply { this.toList().shouldNotContainAny(expected) }
 
+infix fun CharArray.shouldBeSortedAccordingTo(comparator: Comparator<Char>) = apply {
+    var index = 0
+    toList().zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("ByteArray is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nByteArray was:\n <$this>")
+        index++
+    }
+}
+
 infix fun Char.shouldBeIn(theArray: CharArray) = apply { this shouldBeIn theArray.toTypedArray() }
 
 infix fun Char.shouldNotBeIn(theArray: CharArray) = apply { this shouldNotBeIn theArray.toTypedArray() }
@@ -288,6 +327,14 @@ infix fun DoubleArray.shouldMatchAtLeastOneOf(predicate: (Double) -> Boolean) =
 
 infix fun DoubleArray.shouldMatchAllWith(predicate: (Double) -> Boolean) = apply { this.toList().shouldMatchAllWith(predicate) }
 
+infix fun DoubleArray.shouldBeSortedAccordingTo(comparator: Comparator<Double>) = apply {
+    var index = 0
+    toList().zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("DoubleArray is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nDoubleArray was:\n <$this>")
+        index++
+    }
+}
+
 infix fun Double.shouldBeIn(theArray: DoubleArray) = apply { this shouldBeIn theArray.toTypedArray() }
 
 infix fun Double.shouldNotBeIn(theArray: DoubleArray) = apply { this shouldNotBeIn theArray.toTypedArray() }
@@ -332,6 +379,14 @@ infix fun FloatArray.shouldNotContainAny(expected: FloatArray) = apply { expecte
 
 infix fun FloatArray.shouldNotContainAny(expected: Iterable<Float>) = apply { this.toList().shouldNotContainAny(expected) }
 
+infix fun FloatArray.shouldBeSortedAccordingTo(comparator: Comparator<Float>) = apply {
+    var index = 0
+    toList().zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("FloatArray is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nFloatArray was:\n <$this>")
+        index++
+    }
+}
+
 infix fun Float.shouldBeIn(theArray: FloatArray) = apply { this shouldBeIn theArray.toTypedArray() }
 
 infix fun Float.shouldNotBeIn(theArray: FloatArray) = apply { this shouldNotBeIn theArray.toTypedArray() }
@@ -380,6 +435,14 @@ infix fun LongArray.shouldNotContainAny(expected: LongArray) = apply { expected.
 
 infix fun LongArray.shouldNotContainAny(expected: Iterable<Long>) = apply { this.toList().shouldNotContainAny(expected) }
 
+infix fun LongArray.shouldBeSortedAccordingTo(comparator: Comparator<Long>) = apply {
+    var index = 0
+    toList().zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("LongArray is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nLongArray was:\n <$this>")
+        index++
+    }
+}
+
 infix fun Long.shouldBeIn(theArray: LongArray) = apply { this shouldBeIn theArray.toTypedArray() }
 
 infix fun Long.shouldNotBeIn(theArray: LongArray) = apply { this shouldNotBeIn theArray.toTypedArray() }
@@ -388,7 +451,6 @@ infix fun LongArray.shouldMatchAtLeastOneOf(predicate: (Long) -> Boolean) = appl
 
 infix fun LongArray.shouldMatchAllWith(predicate: (Long) -> Boolean) = apply { this.toList().shouldMatchAllWith(predicate) }
 
-
 infix fun ShortArray.shouldEqual(expected: ShortArray) = apply { assertArrayEquals(this.toTypedArray(), expected.toTypedArray()) }
 
 infix fun ShortArray.shouldNotEqual(expected: ShortArray) = apply { assertArrayNotEquals(this.toTypedArray(), expected.toTypedArray()) }
@@ -433,6 +495,14 @@ infix fun ShortArray.shouldMatchAtLeastOneOf(predicate: (Short) -> Boolean) = ap
 
 infix fun ShortArray.shouldMatchAllWith(predicate: (Short) -> Boolean) = apply { this.toList().shouldMatchAllWith(predicate) }
 
+infix fun ShortArray.shouldBeSortedAccordingTo(comparator: Comparator<Short>) = apply {
+    var index = 0
+    toList().zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("ShortArray is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nShortArray was:\n <$this>")
+        index++
+    }
+}
+
 infix fun Short.shouldBeIn(theArray: ShortArray) = apply { this shouldBeIn theArray.toTypedArray() }
 
 infix fun Short.shouldNotBeIn(theArray: ShortArray) = apply { this shouldNotBeIn theArray.toTypedArray() }
@@ -501,6 +571,14 @@ infix fun <I : Iterable<*>> I.shouldHaveSize(expectedSize: Int) = apply {
     }
 }
 
+infix fun <T, I : Iterable<T>> I.shouldBeSortedAccordingTo(comparator: Comparator<T>) = apply {
+    var index = 0
+    zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("Iterable is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nIterable was:\n <$this>")
+        index++
+    }
+}
+
 @Deprecated("Equality should not be tested on sequences", level = DeprecationLevel.ERROR)
 infix fun <T, S : Sequence<T>> S.shouldEqual(expected: Sequence<T>): S =
         fail("Equality should not be tested on sequences")
@@ -509,6 +587,14 @@ infix fun <T, S : Sequence<T>> S.shouldEqual(expected: Sequence<T>): S =
 infix fun <T, S : Sequence<T>> S.shouldNotEqual(expected: Sequence<T>): S =
         fail("Equality should not be tested on sequences")
 
+infix fun <T, S : Sequence<T>> S.shouldBeSortedAccordingTo(comparator: Comparator<T>) = apply {
+    var index = 0
+    zipWithNext { a, b ->
+        if (comparator.compare(a, b) > 0) fail("Sequence is not sorted according to $comparator comparator because element $index:\n <$a>\nis not less or equal than element ${index + 1}:\n <$b>\nSequence was:\n <$this>")
+        index++
+    }
+}
+
 fun <S : Sequence<*>> S.shouldBeEmpty(): S = apply { assertEmpty(asIterable(), "Sequence") }
 fun <S : Sequence<*>> S.shouldNotBeEmpty(): S = apply { assertNotEmpty(asIterable(), "Sequence") }
 
diff --git a/jvm/src/main/kotlin/org/amshove/kluent/CollectionsBacktick.kt b/jvm/src/main/kotlin/org/amshove/kluent/CollectionsBacktick.kt
index 045b6771..c109502b 100644
--- a/jvm/src/main/kotlin/org/amshove/kluent/CollectionsBacktick.kt
+++ b/jvm/src/main/kotlin/org/amshove/kluent/CollectionsBacktick.kt
@@ -42,12 +42,16 @@ infix fun IntArray.`should not contain`(expected: Int) = this.shouldNotContain(e
 
 infix fun IntArray.`should not contain any`(expected: IntArray) = this.shouldNotContainAny(expected)
 
+infix fun IntArray.`should be sorted according to`(comparator: Comparator<Int>) = this.shouldBeSortedAccordingTo(comparator)
+
 infix fun Int.`should be in`(theArray: IntArray) = this.shouldBeIn(theArray)
 
 infix fun Int.`should not be in`(theArray: IntArray) = this.shouldNotBeIn(theArray)
 
 infix fun BooleanArray.`should equal`(expected: BooleanArray) = this.shouldEqual(expected)
 
+infix fun BooleanArray.`should be sorted according to`(comparator: Comparator<Boolean>) = this.shouldBeSortedAccordingTo(comparator)
+
 fun BooleanArray.`should be empty`() = this.shouldBeEmpty()
 
 fun BooleanArray.`should not be empty`() = this.shouldNotBeEmpty()
@@ -80,6 +84,8 @@ fun ByteArray.`should not be empty`() = this.shouldNotBeEmpty()
 
 infix fun ByteArray.`should contain`(expected: Byte) = this.shouldContain(expected)
 
+infix fun ByteArray.`should be sorted according to`(comparator: Comparator<Byte>) = this.shouldBeSortedAccordingTo(comparator)
+
 @Deprecated("Use `should contain any`", ReplaceWith("this `should contain any` check"))
 infix fun ByteArray.`should contain some`(expected: ByteArray) = this.shouldContainSome(expected)
 
@@ -105,6 +111,8 @@ fun CharArray.`should not be empty`() = this.shouldNotBeEmpty()
 
 infix fun CharArray.`should contain`(expected: Char) = this.shouldContain(expected)
 
+infix fun CharArray.`should be sorted according to`(comparator: Comparator<Char>) = this.shouldBeSortedAccordingTo(comparator)
+
 @Deprecated("Use `should contain any`", ReplaceWith("this `should contain any` check"))
 infix fun CharArray.`should contain some`(expected: CharArray) = this.shouldContainSome(expected)
 
@@ -128,6 +136,8 @@ fun DoubleArray.`should be empty`() = this.shouldBeEmpty()
 
 fun DoubleArray.`should not be empty`() = this.shouldNotBeEmpty()
 
+infix fun DoubleArray.`should be sorted according to`(comparator: Comparator<Double>) = this.shouldBeSortedAccordingTo(comparator)
+
 infix fun DoubleArray.`should contain`(expected: Double) = this.shouldContain(expected)
 
 @Deprecated("Use `should contain any`", ReplaceWith("this `should contain any` check"))
@@ -168,6 +178,8 @@ infix fun FloatArray.`should not contain`(expected: Float) = this.shouldNotConta
 
 infix fun FloatArray.`should not contain any`(expected: FloatArray) = this.shouldNotContainAny(expected)
 
+infix fun FloatArray.`should be sorted according to`(comparator: Comparator<Float>) = this.shouldBeSortedAccordingTo(comparator)
+
 infix fun Float.`should be in`(theArray: FloatArray) = this.shouldBeIn(theArray)
 
 infix fun Float.`should not be in`(theArray: FloatArray) = this.shouldNotBeIn(theArray)
@@ -193,6 +205,8 @@ infix fun LongArray.`should not contain`(expected: Long) = this.shouldNotContain
 
 infix fun LongArray.`should not contain any`(expected: LongArray) = this.shouldNotContainAny(expected)
 
+infix fun LongArray.`should be sorted according to`(comparator: Comparator<Long>) = this.shouldBeSortedAccordingTo(comparator)
+
 infix fun Long.`should be in`(theArray: LongArray) = this.shouldBeIn(theArray)
 
 infix fun Long.`should not be in`(theArray: LongArray) = this.shouldNotBeIn(theArray)
@@ -218,6 +232,8 @@ infix fun ShortArray.`should not contain`(expected: Short) = this.shouldNotConta
 
 infix fun ShortArray.`should not contain any`(expected: ShortArray) = this.shouldNotContainAny(expected)
 
+infix fun ShortArray.`should be sorted according to`(comparator: Comparator<Short>) = this.shouldBeSortedAccordingTo(comparator)
+
 infix fun Short.`should be in`(theArray: ShortArray) = this.shouldBeIn(theArray)
 
 infix fun Short.`should not be in`(theArray: ShortArray) = this.shouldNotBeIn(theArray)
@@ -252,6 +268,8 @@ fun <I : Iterable<*>> I.`should be empty`(): I = this.shouldBeEmpty()
 
 fun <I : Iterable<*>> I.`should not be empty`(): I = this.shouldNotBeEmpty()
 
+infix fun <T, I : Iterable<T>> I.`should be sorted according to`(comparator: Comparator<T>) = this.shouldBeSortedAccordingTo(comparator)
+
 infix fun <K, M : Map<K, *>> M.`should have key`(theKey: K): M = this.shouldHaveKey(theKey)
 
 infix fun <K, M : Map<K, *>> M.`should not have key`(theKey: K): M = this.shouldNotHaveKey(theKey)


Test patch:
diff --git a/common/src/test/kotlin/org/amshove/kluent/collections/ShouldBeSortedAccordingToShould.kt b/common/src/test/kotlin/org/amshove/kluent/collections/ShouldBeSortedAccordingToShould.kt
new file mode 100644
index 00000000..5c903538
--- /dev/null
+++ b/common/src/test/kotlin/org/amshove/kluent/collections/ShouldBeSortedAccordingToShould.kt
@@ -0,0 +1,259 @@
+package org.amshove.kluent.collections
+
+import org.amshove.kluent.Person
+import org.amshove.kluent.shouldBeSortedAccordingTo
+import kotlin.random.Random
+import kotlin.test.Test
+import kotlin.test.assertFails
+
+class ShouldBeSortedAccordingToShould {
+    private val intComparator = Comparator { a: Int, b: Int -> a.compareTo(b) }
+    private val booleanComparator = Comparator { a: Boolean, b: Boolean -> a.compareTo(b) }
+    private val byteComparator = Comparator { a: Byte, b: Byte -> a.compareTo(b) }
+    private val charComparator = Comparator { a: Char, b: Char -> a.compareTo(b) }
+    private val doubleComparator = Comparator { a: Double, b: Double -> a.compareTo(b) }
+    private val floatComparator = Comparator { a: Float, b: Float -> a.compareTo(b) }
+    private val longComparator = Comparator { a: Long, b: Long -> a.compareTo(b) }
+    private val shortComparator = Comparator { a: Short, b: Short -> a.compareTo(b) }
+    private val personComparator = Comparator { a: Person, b: Person -> a.name.compareTo(b.name) }
+
+    @Test
+    fun passWhenTestingEmptyArray() {
+        val array = emptyArray<Int>()
+        array shouldBeSortedAccordingTo intComparator
+    }
+
+    @Test
+    fun passWhenTestingSingleItemArray() {
+        val array = arrayOf(Random.nextInt())
+        array shouldBeSortedAccordingTo intComparator
+    }
+
+    @Test
+    fun passWhenTestingSortedArray() {
+        val array = arrayOf(1, 2, 3)
+        array shouldBeSortedAccordingTo intComparator
+    }
+
+    @Test
+    fun failWhenTestingUnsortedArray() {
+        val array = arrayOf(1, 5, 3)
+        assertFails { array shouldBeSortedAccordingTo intComparator }
+    }
+
+    @Test
+    fun passWhenTestingEmptyIntArray() {
+        val array = intArrayOf()
+        array shouldBeSortedAccordingTo intComparator
+    }
+
+    @Test
+    fun passWhenTestingSingleItemIntArray() {
+        val array = intArrayOf(Random.nextInt())
+        array shouldBeSortedAccordingTo intComparator
+    }
+
+    @Test
+    fun passWhenTestingSortedIntArray() {
+        val array = intArrayOf(1, 2, 3)
+        array shouldBeSortedAccordingTo intComparator
+    }
+
+    @Test
+    fun failWhenTestingUnsortedIntArray() {
+        val array = intArrayOf(1, 5, 3)
+        assertFails { array shouldBeSortedAccordingTo intComparator }
+    }
+
+    @Test
+    fun passWhenTestingEmptyBooleanArray() {
+        val array = booleanArrayOf()
+        array shouldBeSortedAccordingTo booleanComparator
+    }
+
+    @Test
+    fun passWhenTestingSingleItemBooleanArray() {
+        val array = booleanArrayOf(Random.nextBoolean())
+        array shouldBeSortedAccordingTo booleanComparator
+    }
+
+    @Test
+    fun passWhenTestingSortedBooleanArray() {
+        val array = booleanArrayOf(false, false, true, true)
+        array shouldBeSortedAccordingTo booleanComparator
+    }
+
+    @Test
+    fun failWhenTestingUnsortedBooleanArray() {
+        val array = booleanArrayOf(true, false, false)
+        assertFails { array shouldBeSortedAccordingTo booleanComparator }
+    }
+
+    @Test
+    fun passWhenTestingEmptyByteArray() {
+        val array = byteArrayOf()
+        array shouldBeSortedAccordingTo byteComparator
+    }
+
+    @Test
+    fun passWhenTestingSingleItemByteArray() {
+        val array = Random.nextBytes(1)
+        array shouldBeSortedAccordingTo byteComparator
+    }
+
+    @Test
+    fun passWhenTestingSortedByteArray() {
+        val array = byteArrayOf(1, 2, 3)
+        array shouldBeSortedAccordingTo byteComparator
+    }
+
+    @Test
+    fun failWhenTestingUnsortedByteArray() {
+        val array = byteArrayOf(1, 5, 3)
+        assertFails { array shouldBeSortedAccordingTo byteComparator }
+    }
+
+    @Test
+    fun passWhenTestingEmptyCharArray() {
+        val array = charArrayOf()
+        array shouldBeSortedAccordingTo charComparator
+    }
+
+    @Test
+    fun passWhenTestingSingleItemCharArray() {
+        val array = charArrayOf(Random.nextInt().toChar())
+        array shouldBeSortedAccordingTo charComparator
+    }
+
+    @Test
+    fun passWhenTestingSortedCharArray() {
+        val array = charArrayOf('a', 'b', 'c')
+        array shouldBeSortedAccordingTo charComparator
+    }
+
+    @Test
+    fun failWhenTestingUnsortedCharArray() {
+        val array = charArrayOf('a', 'o', 'b', 'c')
+        assertFails { array shouldBeSortedAccordingTo charComparator }
+    }
+
+    @Test
+    fun passWhenTestingEmptyDoubleArray() {
+        val array = doubleArrayOf()
+        array shouldBeSortedAccordingTo doubleComparator
+    }
+
+    @Test
+    fun passWhenTestingSingleItemDoubleArray() {
+        val array = doubleArrayOf(Random.nextDouble())
+        array shouldBeSortedAccordingTo doubleComparator
+    }
+
+    @Test
+    fun passWhenTestingSortedDoubleArray() {
+        val array = doubleArrayOf(1.0, 2.0, 3.0)
+        array shouldBeSortedAccordingTo doubleComparator
+    }
+
+    @Test
+    fun failWhenTestingUnsortedDoubleArray() {
+        val array = doubleArrayOf(1.0, 5.0, 3.0)
+        assertFails { array shouldBeSortedAccordingTo doubleComparator }
+    }
+
+    @Test
+    fun passWhenTestingEmptyFloatArray() {
+        val array = floatArrayOf()
+        array shouldBeSortedAccordingTo floatComparator
+    }
+
+    @Test
+    fun passWhenTestingSingleItemFloatArray() {
+        val array = floatArrayOf(Random.nextFloat())
+        array shouldBeSortedAccordingTo floatComparator
+    }
+
+    @Test
+    fun passWhenTestingSortedFloatArray() {
+        val array = floatArrayOf(1f, 2f, 3f)
+        array shouldBeSortedAccordingTo floatComparator
+    }
+
+    @Test
+    fun failWhenTestingUnsortedFloatArray() {
+        val array = floatArrayOf(1f, 5f, 3f)
+        assertFails { array shouldBeSortedAccordingTo floatComparator }
+    }
+
+    @Test
+    fun passWhenTestingEmptyLongArray() {
+        val array = longArrayOf()
+        array shouldBeSortedAccordingTo longComparator
+    }
+
+    @Test
+    fun passWhenTestingSingleItemLongArray() {
+        val array = longArrayOf(Random.nextLong())
+        array shouldBeSortedAccordingTo longComparator
+    }
+
+    @Test
+    fun passWhenTestingSortedLongArray() {
+        val array = longArrayOf(1, 2, 3)
+        array shouldBeSortedAccordingTo longComparator
+    }
+
+    @Test
+    fun failWhenTestingUnsortedLongArray() {
+        val array = longArrayOf(1, 5, 3)
+        assertFails { array shouldBeSortedAccordingTo longComparator }
+    }
+
+    @Test
+    fun passWhenTestingEmptyShortArray() {
+        val array = shortArrayOf()
+        array shouldBeSortedAccordingTo shortComparator
+    }
+
+    @Test
+    fun passWhenTestingSingleItemShortArray() {
+        val array = shortArrayOf(Random.nextInt().toShort())
+        array shouldBeSortedAccordingTo shortComparator
+    }
+
+    @Test
+    fun passWhenTestingSortedShortArray() {
+        val array = shortArrayOf(1, 2, 3)
+        array shouldBeSortedAccordingTo shortComparator
+    }
+
+    @Test
+    fun failWhenTestingUnsortedShortArray() {
+        val array = shortArrayOf(1, 5, 3)
+        assertFails { array shouldBeSortedAccordingTo shortComparator }
+    }
+
+    @Test
+    fun passWhenTestingEmptyIterable() {
+        val iterable = emptyList<Person>()
+        iterable shouldBeSortedAccordingTo personComparator
+    }
+
+    @Test
+    fun passWhenTestingSingleItemIterable() {
+        val iterable = listOf(Person("Alice", "Bob"))
+        iterable shouldBeSortedAccordingTo personComparator
+    }
+
+    @Test
+    fun passWhenTestingSortedIterable() {
+        val iterable = listOf(Person("Alice", "Bob"), Person("Jon", "Doe"), Person("Tom", "Guy"))
+        iterable shouldBeSortedAccordingTo personComparator
+    }
+
+    @Test
+    fun failWhenTestingUnsrotedIterable() {
+        val iterable = listOf(Person("Jon", "Doe"), Person("Tom", "Guy"), Person("Peter", "Meyer"))
+        assertFails { iterable shouldBeSortedAccordingTo personComparator }
+    }
+}