Hey guys! Does anyone knows how to order big lists...
# server
g
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
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
@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
You can parallise quicksort to some degree but that actually may not be faster than a merge sort; really depends on your data
1