Quantcast
Channel: Day to day stuff
Viewing all articles
Browse latest Browse all 83

Having fun with Ordering in Scala

$
0
0
Challenge: sort a list of objects by name, but some names have priority. If these names appear, they should be ordered by the position they have in the priority list. For example: val priorityList = Seq("Willow", "James", "Ezra") val input = Seq("Olivier", "Charlotte", "Willow", "Declan", "Aurora", "Ezra") val ordered = ??? assert(ordered == Seq("Willow", "Ezra", "Aurora", "Charlotte", "Declan"

Viewing all articles
Browse latest Browse all 83

Trending Articles