Use minBy { selector } instead of sortedBy { selector }.first()
ProprietarysortedBy(f).first() does an O(n log n) sort just to read the minimum-by-f. minBy(f) finds it in a single linear pass.
org. openrewrite. kotlin. performance. UseMinByForSortedByFirst$KtRecipemod run . --recipe= 'org. openrewrite. kotlin. performance. UseMinByForSortedByFirst$KtRecipe'Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.