I have the following type of data:
case class TipoDeDato[T] (nombreCampo: String,valor: T)
And in my exercise, I need to create the following structure, using the type of data I mentioned:
So, I created the following structure
val registro0: List[TipoDeDato[_>: String with Int]] = List(
new TipoDeDato[String]("Autor", "Gabo"),
new TipoDeDato[String]("Titulo", "100 Años"),
new TipoDeDato[Int]("Numero de Paginas", 700)
)
val registro1: List[TipoDeDato[_>: String with Int]] = List(
new TipoDeDato[String]("Autor", "Gabo"),
new TipoDeDato[String]("Titulo", "Maria"),
new TipoDeDato[Int]("Numero de Paginas", 1200)
)
val registro2: List[TipoDeDato[_>: String with Int]] = List(
new TipoDeDato[String]("Autor", "Gabo"),
new TipoDeDato[String]("Titulo", "Carrasco"),
new TipoDeDato[Int]("Numero de Paginas", 150)
)
val registro3: List[TipoDeDato[_>: String with Int]] = List(
new TipoDeDato[String]("Autor", "Gabo"),
new TipoDeDato[String]("Titulo", "Oceano"),
new TipoDeDato[Int]("Numero de Paginas", 200)
)
And to create the "Libros" object, I have done the following:
val Libros: List[List[TipoDeDato[_>: String with Int]]] = List(registro0,registro1,registro2,registro3)
My question is, how can I sort the "Libros" object, by any of its components, "Autor", "Titulo", "Numero de paginas"?, is this structure adequate for what I need to do?