https://kotlinlang.org logo
Title
g

Guilherme Gomes Correia

10/29/2021, 9:37 PM
Hey guys! Does anyone knows how to order big lists in Kotlin with great performance? Is it possible to use parallel stream? Basically, I have a list of almost 100k records and need to order based on two fields: ID (string) and Date(OffsetDateTime).
p

Paul Griffith

10/31/2021, 9:59 PM
Sorting isn't generally an operation you can run in parallel, because you need to be aware of your neighboring elements. If I may, this sounds like it might be premature optimization; have you actually proved via benchmarking that sorting is the slow part of your code? It's probably faster than you'd think
s

Shawn

11/01/2021, 4:57 PM
@Paul Griffith agreed that this is probably premature optimization, but mergesort can be parallelized pretty well and even quicksort has decent parallel variants
👍 1
r

Robert MacLean

11/02/2021, 6:47 AM
You can parallise quicksort to some degree but that actually may not be faster than a merge sort; really depends on your data
1