How to reorder
List(Map(d -> 4, a -> 1, c -> 3, b -> 2), Map(d -> 8, a -> 2, c -> 6, b -> 4))
to
List(Map(a -> 1, b -> 2, c -> 3, d -> 4), Map(a -> 2, b -> 4, c -> 6, d -> 8))
using Scala?
How to reorder
List(Map(d -> 4, a -> 1, c -> 3, b -> 2), Map(d -> 8, a -> 2, c -> 6, b -> 4))
to
List(Map(a -> 1, b -> 2, c -> 3, d -> 4), Map(a -> 2, b -> 4, c -> 6, d -> 8))
using Scala?
import scala.collection.immutable.SortedMap
val a = Map('d' -> 4, 'a' -> 1, 'c' -> 3, 'b' -> 2)
val b = Map('d' -> 8, 'a' -> 2, 'c' -> 6, 'b' -> 4)
val c = List(a, b)
val d = c.map(SortedMap[Char, Int]() ++ _)
You can map over the contents of c and create a new SortedMap from the contents of each map.