How to sort a Scala List[Map[String, Any]] by an arbitrary number of keys in the Map? -
i have list[map[string, any]]
represents results of query.
the keys of map instance (or row) column names.
each query different , result may contain different set of columns, compared other query. queries cannot predicted in advance, hence cannot use case classes represent result row.
within results given query, columns appear in every row.
the values largely int
, double
, string
types.
i need able sort results multiple columns, in both ascending , descending order.
for example, in pseudocode / sql:
order column1 asc, column2 desc, column3 asc
i have 3 distinct problems:
- sort single column type (in map, opposed underlying type)
any
- sort either direction
- chain multiple sort instructions together
how can this?
update
i can part 1. , part 2. writing custom ordering[any]. don't yet know how chain sorts together.
Comments
Post a Comment