Given and Using
Exercise 1
val cities = List("London", "Paris", "Lisbon", "Berlin")
Create a list of cities:
- sort the list of cities in ascending order
- sort in list of cities in descending order
- Put the two ordering function in their own scope
- Choice which order you use with the
import
Create a case class CapitalCity with a city and a country Create a list of capital cities
- sort the capital cities in ascending order on the country name
- sort the capital cities in descending order in the city name
- Add the first ordering in the companion object and the second a separate object
- Choice which order you use with the
import
Exercise 2
val names = List("John", "Alice", "Jane", "Edward")
Create a list of names:
- sort the names in ascending order
- sort in names in descending order
- Put the two ordering function in their own scope
- Choice which order you use with the
import
Create a case class Person with a name and age Create a list of persons
- sort the persons in ascending order on the age
- sort the persons in descending order on the age
- Add the ascending ordering in the companion object and the descending a separate scope
- Choice which order you use with the
import