Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SortTest {
- @Test
- fun `sorting`() {
- DUMMY.sortedWith(
- compareByDescending<SortItem> { it.bool }
- .thenBy { it.num }
- .thenBy { it.date }
- .thenBy { it.name }
- ).print()
- }
- private fun <T> List<T>.print() {
- println(this.joinToString("\n"))
- }
- companion object {
- private val DUMMY = arrayListOf(
- SortItem(true, 5, Instant.now().plusSeconds(60), "A"),
- SortItem(false, 5, Instant.now().plusSeconds(120), "B"),
- SortItem(true, 10, Instant.now().plusSeconds(180), "C"),
- SortItem(true, 20, Instant.now().plusSeconds(180), "D"),
- SortItem(false, 5, Instant.now().plusSeconds(60), "E")
- )
- }
- }
- data class SortItem(
- val bool: Boolean,
- val num: Int,
- val date: Instant,
- val name: String
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement