Govind Singh
Govind Singh

Reputation: 15490

how to sort Map[Int,Map[String,String]] according to inner map value

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

Upvotes: 0

Views: 111

Answers (1)

gzm0
gzm0

Reputation: 14842

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.

Upvotes: 3

Related Questions