I'm storing the Hazelcast JSON value in IMAP
IMap.put(Integer,new HazelcastjsonValue("{"id":"001","name":"vikram"}"));
IMap.put(Integer,new HazelcastjsonValue("{"id":"002","name":"abhishek"}"));
How to sort the HazelcastjsonValue by name
I know using paging predicate we can achieve a sorted JSON array.
But how to use the paging predicate for the HazelcastjsonValue.
Can anyone please help me with this?
You can set an index as described in Hazelcast Reference Manual: Indexing Queries. In your case, it would look like:
IMap.addIndex(new IndexConfig(IndexType.SORTED, "name"));
Then, the result collection should be sorted.
If you don't want to set an index, then I guess you can use Predicates.pagingPredicate(comparator, size)
, but you would need write your own custom comparator.