I’m using hazelcast IMap[String,Any] in my application. When printing the map it should be sorted by the keys.
Is there a nice way to sort the IMap by key (other than sort the keys locally and print by the sorted keys)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since
IMapextends the regularjava.util.Mapyou could use ascala.collection.immutable.TreeMap, which is always sorted by keys.This obviously does not come for free because you need to iterate over the
IMapand sort it each time you want to print it.