0

How to sort Map[Int,Map[String,String]]?

var data=Map(1416479696353 -> Map(name -> You,savePoint -> 4), 1416479788969 -> Map(name -> You, savePoint -> 9), 1416479801372 -> Map(name -> govind,savePoint -> 10))

i want to sort above map according to savePoint

Govind Singh
  • 15,282
  • 14
  • 72
  • 106

1 Answers1

3

Use sortBy:

data.toSeq.sortBy(_._2("savePoint").toInt)

This will give you a List[(Int, Map[String, String])]. If you only need the values of data, you can sort data.values.toSeq instead.

Govind Singh
  • 15,282
  • 14
  • 72
  • 106
gzm0
  • 14,752
  • 1
  • 36
  • 64