Dave's given the solution I'd use. In general, you create properties that map well to the type of queries you're going to use, especially since you can only use inequalities on one property. You do upfront processing if necessary at write time (e.g., the put() override in Dave's solution) so your read time queries are simpler and fast.
-Bill On Mar 28, 10:22 pm, David Symonds <dsymo...@gmail.com> wrote: > On Sun, Mar 29, 2009 at 3:01 PM, manuelaraoz <manuelar...@gmail.com> wrote: > > class Person(db.Model): > > > age = IntegerProperty() > > height_in_cm = IntegerProperty() > > > how can I sort first by age, but if I have two people with the same > > age, to sort them by height_in_cm > > You could create a synthetic property that you sort on instead: > > age_height_sort = db.IntegerProperty() > > You can set it in a put() override: > > def put(self): > self.age_height_sort = self.age*1000 + self.height_in_cm > return super(Person, self).put() > > Then you can just order by that synthetic property: > > Person.all().order('age_height_sort') > > Dave. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---