how would i do this? and how could i influence the behaviour of the order of a query result?
On Jan 25, 2012, at 2:38 AM, Robert Kluin wrote: > Hey Andreas, > You could actually include this as a computed property on your entity, the > order by the computed property. I often do this to normalize (lower-case, > strip punctuation, etc...) names for searching. > > > Robert > > > > > On Tuesday, January 24, 2012, Andreas <[email protected]> wrote: > > im actually wondering why calling .order() on a string property returns an > > ascii order and not a human expected order. > > i understand that this is the default behaviour of most (all?) languages > > but who the hell would like an ascii order on a query? > > > > lets say we store filenames as a StringProperty() and we want to order on > > them. > > > > lets say the filenames are: > > 1.jpg > > 2.jpg > > 11.jpg > > 12.jpg > > > > right now the order returned would be: > > 1.jpg > > 11.jpg > > 12.jpg > > 2.jpg > > > > i actually dont know who actually would be happy with an order like that. > > > > what it should return is: > > 1.jpg > > 2.jpg > > 11.jpg > > 12.jpg > > > > of course!!! > > > > right now i have to add a custom sort function to sort results in memory > > after fetching them. which also means i cant use this for batching and > > keys_only queries. > > this is pretty sad! > > > > this function helps: > > > > def sort_nicely(l, reverse=False): > > """ Sort the given list in the way that humans expect. """ > > convert = lambda text: int(text) if text.isdigit() else text > > alphanum_key = lambda entry: [convert(e) for e in re.split('([0-9]+)', > > entity.filename)] > > l.sort(key=alphanum_key) > > if reverse: > > l.reverse() > > return l > > > > so why not including a function like that into the query language? > > > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Google App Engine" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > > http://groups.google.com/group/google-appengine?hl=en. > > > > > > -- > ------ > Robert Kluin > Ezox Systems, LLC > > > > > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
