I have developed a custom function which takes Map<String, Object> and List which maintain the order which is applied on map of keys
Map<String, Object> sortedMap = new LinkedHashMap<>();
for (Map<String, Object> map : maps) {
for (String key : keySequence) {
if (map.containsKey(key)) {
sortedMap.put(key, map.get(key));
}
}
System.out.println(sortedMap);
return sortedMap;
this is my java code and built a jar and deployed that into the plugins folder and able to call successfully but when I check this code which is working fine even print statement gives me proper result but when I check the output in neo4j browser or calling neo4j function using cypher through code getting different order.
WITH ['A', 'C', 'F', 'D', 'E', 'B'] AS keySequence,
{D: 1, A: 2, E: 3, B: 4, C: 5, F: 6}
AS mapData RETURN sortedkeys(mapData ,keySequence)
expected output - {A=2, C=5, F=6, D=1, E=3, B=4}
Output in neo4j Browser = {
"A": 2,
"B": 4,
"C": 5,
"D": 1,
"E": 3,
"F": 6
}
- neo4j version; 5.1.0
- java version: 11
- debug log --{A=2, C=5, F=6, D=1, E=3, B=4}
appreciate the time and efforts of the member in advance who want to help me.