View Single Post
Old 06-14-2012, 05:24 PM   #5
cnfmsu
Member
cnfmsu began at the beginning.
 
Posts: 18
Karma: 10
Join Date: Jan 2012
Device: Nook
Hi Kovid

I have a question from this scenario:
1> I am building the articles list without the RSS:
articles.append(dict(title=title, url=url, description=desc, date=date))
2> I like to control how the article is list within the same section
I add another element to the “dict”. E.g.:
articles.append(dict(sortseq=sortseq, title=title, url=url, description=desc, date=date))
3> right before the “feeds.append”, I do a articles.sort()

But it is not sort by “sortseq”.
I have tried with these kind of format:
s = sorted(s, key = lambda x: (x[1], x[2]))
s = sorted(s, key = operator.itemgetter(1, 2))
s.sort(key = operator.itemgetter(1, 2))

Still have the issue. My questions are :
- Am I ok to add “sortseq” to the list?
- If yes, am I doing this right on the sort()? Do you have an example for me?

Regards,
cnfmsu is offline   Reply With Quote