I believe there must be a better way to ask this question, but I couldn't think of it.
Consider this case class:
case class UserLocation(id: Int, dateTime: DateTime, lat: Double, lon: Double)
implicit def dateTimeOrdering: Ordering[DateTime] = Ordering.fromLessThan(_ isAfter _)
val locations: List[UserLocation] = bigListOfUserLocations()
val groupedById = locations.groupBy(_.id)
val sortedByDate = groupedById.map(_._2.sortBy(_.dateTime))
val finalList = sortedByDate.map(_.head)
You're basically there, but you can reduce the last two operations to one with:
val finalList = groupedById.map(_._2.maxBy(_.dateTime))
This is more readable, and more performant, since you just find the biggest item in the group wihtout needing to put the rest in order.