New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent ordering in apoc.coll.sort* #797

Closed
cskardon opened this Issue May 1, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@cskardon
Contributor

cskardon commented May 1, 2018

There is an inconsistency in the default way the apoc.coll.sort methods sort, bearing in mind that the default for Cypher is to order in Ascending, I would expect all the sort methods to also sort in that way by default.

apoc.coll.sort orders in ASC
apoc.coll.sortMaps orders in ASC
apoc.coll.sortMulti orders in DESC
apoc.coll.sortNodes orders in ASC

I think they should all be ASC, as the default is.

Fix wise - it's pretty simple, the problem is - it would be a breaking change, as anyone who is currently using sortMulti and expecting it to work in it's current way would have problems.

If it's something that should be fixed, let me know and I'll get on it, but I won't work on it unless it's decided it's a 'goer'. :)

@jexp

This comment has been minimized.

Member

jexp commented May 1, 2018

yes please fix, this seems to be an oversight, looking forward to your PR

usually, it's asc, if you need desc, then you can reverse the list.

cskardon added a commit to cskardon/neo4j-apoc-procedures that referenced this issue May 2, 2018

@cskardon

This comment has been minimized.

Contributor

cskardon commented May 9, 2018

Should this now be closed as per this comment?

@jexp

This comment has been minimized.

Member

jexp commented May 9, 2018

Probably we should make it clearer in the documentation.

The other ones are by default ascending b/c there is no means to indicate sort order (AFAIR).

@cskardon

This comment has been minimized.

Contributor

cskardon commented May 9, 2018

From what I can see - your memory serves you correctly - So.

Given "99% of cases are descending..." should

  1. The others be switched to DESC by default
  2. Nothing be done

Something to consider (in my view) is whether APOC would want a 'DESC' order for the other sorts - I know you can just reverse them, but that seems a bit cludgy..

If I considered doing the latter option of adding a DESC option - I would add a 'properties' thing like the other methods have, so:

apoc.coll.sortNodes(COLLECT(t), 'Name', {desc: true})

Which I think is clearer and doesn't rely on string parsing.

@conker84 conker84 closed this Nov 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment