Skip to content
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

Natural order sorting #106

Closed
jonashaag opened this issue Feb 20, 2012 · 5 comments
Closed

Natural order sorting #106

jonashaag opened this issue Feb 20, 2012 · 5 comments

Comments

@jonashaag
Copy link
Contributor

http://stackoverflow.com/questions/9363926/using-django-mongodb-how-to-sort-descending-a-capped-collection

Syntax could be

Foo.objects.order_by('-natural')

Edit: maybe better

Foo.objects.reverse()

Btw we don't support reverse() (not sure about djangoappengine)

@flaper87
Copy link
Member

What if there's a field called natural ?

jonashaag added a commit that referenced this issue Feb 20, 2012
@jonashaag
Copy link
Contributor Author

good point Flavio, my other proposal doesn't have that problem

@wrwrwr
Copy link
Member

wrwrwr commented Mar 17, 2012

I've just realized one thing about my solution -- $natural is always added when no field ordering is given (using order_by or ordering). As far as I understand, if the ordering is not reversed (through QuerySet.reverse or Manager.reverse), it will have no effect, even if some constraints are used; is this right? Would it be any better to skip {$natural: ASCENDING} completely?

@jonashaag
Copy link
Contributor Author

yeah.

@jonashaag
Copy link
Contributor Author

54da303 and 1585e90

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

No branches or pull requests

3 participants