Skip to content

Instantly share code, notes, and snippets.

@adamw
Created October 31, 2019 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamw/1a1df65ee2c1b973b14e9331426f8911 to your computer and use it in GitHub Desktop.
Save adamw/1a1df65ee2c1b973b14e9331426f8911 to your computer and use it in GitHub Desktop.
case class LetterAndCount(letter: String, count: Int)
// result: Response[GitHubResult] is what we've read from the API
val firstLetterToName = result.items.groupBy(_.name.toUpperCase.charAt(0))
val pairs = firstLetterToName.toList.map { case (letter, projects) =>
LetterAndCount(letter.toString, projects.size)
}.sortBy(_.letter)
pairs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment