Skip to content

Instantly share code, notes, and snippets.

@Krasnyanskiy
Last active July 24, 2016 23:00
Show Gist options
  • Save Krasnyanskiy/52522cf020fe5b169c1bd9c84a4faeb1 to your computer and use it in GitHub Desktop.
Save Krasnyanskiy/52522cf020fe5b169c1bd9c84a4faeb1 to your computer and use it in GitHub Desktop.
-scala: sorting via reduce
val res = text.map(_.split(" ").size).sortBy(identity).collect.toList
@Krasnyanskiy
Copy link
Author

val result = text.map(line => line.split(" ").size).reduce((a, b) => if (a > b) a else b)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment