If it's Scala in the template layer and you LHMap is getting silently
converted to a Scala immutable Map, you could try:
@import scala.collection.immutable.ListMap
@ListMap( categories.toList.sortBy(_._1):_* )
or, break that bit out if you're going to need proper sorting
application-wide (one would assume so ;-))
// views/utils/Foo.scala
object FooUtils {
class MapSort(m: Map[String,String]) {
import scala.collection.immutable.ListMap
def keySort = ListMap( m.toList.sortBy(_._1):_* )
}
@inline implicit final def sortedMap(m: Map[String,String]) = new
MapSort(m)
}
and then in your views:
@import views.utils.FooUtils._
@categories.keySort
Of course, not sure if any of this applies to Play Java, so FWIW...