Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Google App Engine

You're reading from   Mastering Google App Engine Build robust and highly scalable web applications with Google App Engine

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher
ISBN-13 9781784396671
Length 368 pages
Edition 1st Edition
Languages
Arrow right icon
Toc

Sorting


Now we are comfortable with querying the data, it is time to put it in some desirable order. That is, sorting the results. How do we do that? Our old friend search.QueryOptions takes a keyword argument called sort_options. We just have to supply that and we are done. Okay, so the question is what this sort_options argument would be?

It's actually an instance of search.SortOptions class which takes a single argument called expressions. What is expressions then? It is just a list of search.SortExpression instances where search.SortExpression constructor takes some keyword arguments which define the sorting behavior.

All this seems bit complicated so let's take another look.

  • Whenever you are going to sort, you are either going to sort on a field or a calculated value. For example, you might want to sort on price, which is just a field or price per square feet that is a calculated field obtained by dividing price to size field.

  • But that was just for the value but as we know it is not mandatory...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime