The Unit test code from the simplegraph-core testsuite below displays the region count of airports but it is not ordered as I would have expected.
The result starts with:
NZ-BOP= 3
MZ-A= 1
MZ-B= 1
IN-TN= 5
MZ-N= 1
PW-004= 1
MZ-I= 2
BS-FP= 1
IN-TR= 1
MZ-T= 1
BJ-AQ= 1
GB-ENG= 27
I looked into
- Gremlin group by vertex property and get sum other properties in the same vertex
- Gremlin query for groupcount of last value
and searched for "GroupCount" in questions tagged gremlin to no avail
What is necessary to fix the ordering?
Unit Test see also https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/simplegraph-core/src/test/java/com/bitplan/simplegraph/core/TestTinkerPop3.java
@Test
public void testSortedGroupCount() throws Exception {
Graph graph = getAirRoutes();
GraphTraversalSource g = graph.traversal();
Map<Object, Long> counts = g.V().hasLabel("airport").groupCount()
.by("region").order().by(Order.decr).next();
assertEquals(1473, counts.size());
for (Object key : counts.keySet()) {
System.out.println(String.format("%s=%3d", key, counts.get(key)));
}
}