My Code: <span tal:repeat="item python: sequence.sort(container.news.objectValues ('DTML Document'), (('dateline','cmp','desc'),) )"> What this is doing: Using repeat to create a sequence of "DTML Docs" from my "news" folder. Then it's running a sort of those documents using the "dateline" field and sorting the objects from newest to oldest using cmp function. What my dateline field is: A property: type = string. They look like this "01-25-2003" and so on.... The error: It's returning output similiar to this: 01-13-2003 01-14-2003 01-24-2003 01-31-2002 01-31-2003 02-14-2002 02-26-2002 This is definitely not what I'm after > I'm after the newest date first and then on down. And I can't use the bobobase date b/c some documents get updated at different times (i.e a doc from 2002 could get updated today, but I don't want that to be on top). Any ideas?
At 07:24 AM 2/5/2003, JBeard@porternovelli.com wrote:
What my dateline field is: A property: type = string. They look like this "01-25-2003" and so on....
Well... they're sorting correctly for strings, aren't they? 01-24-2003 comes before 01-31-2002 alphabetically. You'll probably need to do one of the following: 1. Don't store dateline as a string, store it as a float (if you care about time) or long (if you don't) and format it to a string *after* you've done your sort. 2. Format the date as yyyy-mm-dd 3. Devise something to parse dateline and return something that can be correctly sorted, as above. Sort by that but present the original to the user. I find it's quite helpful to have external methods that provide time.strftime() and time.strptime(). You'll probably want to set yourself up with these, get comfortable with them and then it will probably be obvious which solution fits best with your other requirements. If you're running Windoze, you may need to provide strptime on your own. One version of it is here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/56036 HTH, Dylan
participants (2)
-
Dylan Reinhardt -
JBeard@porternovelli.com