thread safe sorted map

besides using Collections to get a synchronized version of a `TreeMap`, another approach to get a output according to sorted key is to do the reverse using a helper class.

for example, using ObjectMapper

//set the ordering
mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);

then to get the output or transform to another object, using the `mapper`

//output
mapper.writeValueAsString(pairs)

//transform
mapper.convertValue(pairs, Map.class)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s