[ 
https://issues.apache.org/jira/browse/TINKERPOP-2520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17282397#comment-17282397
 ] 

Stephen Mallette commented on TINKERPOP-2520:
---------------------------------------------

Use of {{shuffle}} seems to pretty much randomize all results irrespective of 
the chain of comparators. In other words we can order first by a key then by a 
second and so on:

{code}
gremlin> g.V().hasLabel('person').order().by('name',desc).by('age', 
asc).elementMap()
==>[id:2,label:person,name:vadas,age:27]
==>[id:6,label:person,name:peter,age:35]
==>[id:1,label:person,name:marko,age:29]
==>[id:13,label:person,name:marko,age:30]
==>[id:16,label:person,name:marko,age:31]
==>[id:4,label:person,name:josh,age:32]
gremlin> g.V().hasLabel('person').order().by('name',desc).by('age', 
desc).elementMap()
==>[id:2,label:person,name:vadas,age:27]
==>[id:6,label:person,name:peter,age:35]
==>[id:16,label:person,name:marko,age:31]
==>[id:13,label:person,name:marko,age:30]
==>[id:1,label:person,name:marko,age:29]
==>[id:4,label:person,name:josh,age:32]
{code}

but we can't order and then shuffle:

{code}
gremlin> g.V().hasLabel('person').order().by('name',desc).by('age', 
shuffle).elementMap()
==>[id:2,label:person,name:vadas,age:27]
==>[id:16,label:person,name:marko,age:31]
==>[id:4,label:person,name:josh,age:32]
==>[id:13,label:person,name:marko,age:30]
==>[id:1,label:person,name:marko,age:29]
==>[id:6,label:person,name:peter,age:35]
{code}

So, the change suggested above wouldn't be a breaking change from existing 
behavior of the query results. It would only further serve to enforce what is 
already happening. The change is only breaking in the sense that it will now 
throw an exception if you try to do it.


> Add the ability to reverse the stream or a collection
> -----------------------------------------------------
>
>                 Key: TINKERPOP-2520
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-2520
>             Project: TinkerPop
>          Issue Type: Improvement
>          Components: process
>    Affects Versions: 3.4.10
>            Reporter: Kelvin R. Lawrence
>            Priority: Minor
>              Labels: breaking
>
> I had a Gremlin user ask me yesterday if there was a way to have the results 
> of a `path` step be reversed. Today you cannot do that using `from` and `to` 
> steps as the `from` label must appear before the `to` label in a path. In 
> thinking about this, perhaps adding a `reverse` option to order (on top of 
> `asc`,`desc` and `shuffle`) would be a nice addition to Gremlin. So you could 
> write something like:
> {code:java}
> g.V().out().out().path().order(local).by(reverse){code}
> For this specific user they were union-ing a set of paths in different 
> directions and wanted to normalize them to all be in the same direction when 
> presented as results.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to