[
https://issues.apache.org/jira/browse/TINKERPOP-1753?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16133269#comment-16133269
]
ASF GitHub Bot commented on TINKERPOP-1753:
-------------------------------------------
Github user dkuppitz commented on the issue:
https://github.com/apache/tinkerpop/pull/697
Alright, turned out it doesn't have a measurable performance impact.
```
if (first instanceof Number && second instanceof Number) {
return NumberHelper.compare((Number) second, (Number) first);
}
return Comparator.<~>naturalOrder().compare((Comparable) first,
(Comparable) second);
```
is as fast as
```
try {
return Comparator.<~>naturalOrder().compare((Comparable) first,
(Comparable) second);
} catch (final ClassCastException ex) {
if (first instanceof Number && second instanceof Number) {
return NumberHelper.compare((Number) first, (Number) second);
} else throw ex;
}
```
Tested using the Grateful Dead graph and the following query:
```
g.V().hasLabel("song").
project("a","b").
by("name").
by(outE("followedBy").values("weight").sum()).
order().
by(select("b"), decr)
```
Thus I will go with the first variant, not using `try / catch`.
> OrderStep not able to order by non-integer numbers
> --------------------------------------------------
>
> Key: TINKERPOP-1753
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1753
> Project: TinkerPop
> Issue Type: Bug
> Components: process
> Affects Versions: 3.2.5
> Reporter: Daniel Kuppitz
> Assignee: Daniel Kuppitz
>
> {{order()}} and {{order(local)}} sometimes fail to sort by non-integer
> numbers. In some cases it works, but the following pattern (non-integer map
> values?) seems broken:
> {noformat}
> gremlin>
> g.V().hasLabel("person").group().by("name").by(outE().values("weight").sum()).order(local).by(values)
> java.lang.Double cannot be cast to java.lang.Integer
> Type ':help' or ':h' for help.
> Display stack trace? [yN]
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)