order/by a String to Double converted property

9 views
Skip to first unread message

Mihai Bucica

unread,
Jan 22, 2018, 3:41:03 AM1/22/18
to Gremlin-users
I am trying to sort some edges on a 'percent' named property ( String type )  as a Double converted type (e.g. "12.2" -> 12.2 )


The following will sort the edges by 'percent' property as a string:

g.V().hasLabel("Company").has("id","13904073").inE("owns").sort().by(values("percent"))

I know I could also change the schema but i prefer not to for the moment.

I guess I should use a lambda but not sure how to ...


Thanks,

Robert Dale

unread,
Jan 22, 2018, 8:31:17 AM1/22/18
to gremli...@googlegroups.com
Groovy:  g.V().values('percent').order().by(map({Double.valueOf(it.get())}))

Also search for 'map(' in the reference docs.  http://tinkerpop.apache.org/docs/current/reference/

Robert Dale

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/0597bc91-9d85-4af9-90b8-4e1340e42377%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages