0

sorting descending

Hello!

I'd like to fetch some feeds with YQL and then have the result sorted on pubDate in a descending order. I know how to sort in an ascending order, but I guess I don't quite understand the documentation... unsure.gif

Well, here's how I currently do it - I fetch the feeds, sort on pubDate and reverse the output:

CODE
select * from feed where url in ( 'http://www.stern.de/standard/rss.php?channel=all' , 'http://www.spiegel.de/schlagzeilen/index.rss' ) | sort(field="pubDate") | reverse()


Not quite "elegant" cool.gif

According to the docs, it should be possible to have sort return the stuff descendingly, right away, shouldn't it?

How to do that?

Thanks a lot,
Alexander

by
6 Replies
  • This will sort that field descending:

    CODE
    select * from feed where url in ( 'http://www.stern.de/standard/rss.php?channel=all' , 'http://www.spiegel.de/schlagzeilen/index.rss' ) | sort(field="pubDate",descending="true")


    But it likely won't do what you want since I think it uses a lexical sort, not a date sort.

    Sam
    0
  • Hi!

    Ah! descending="true". Cool. Thanks a lot for that!

    You're right, though, it might not do what I want. How might I get, what I want? I suppose, there should be a way to transform the date to ISO format and UTC time zone (ie. something like "2009-04-08 21:04:57" for right now). That way, with ISO format, a lexical sort would work as well.

    How can that most easily be done?

    Cheers,
    Alexander
    0
  • Have you thought of using Yahoo! Pipes? A Fetch Feed module, a Sort module and your done.
    0
  • Hm, yes, maybe.

    Do you know, if there are any usage limits for Yahoo! Pipes?
    0
  • Yes, there is a usage limit, but I've never seen that limit defined. When the limit is hit Pipes returns a 999 error. For a little more detail please see http://discuss.pipes.yahoo.com/Message_Boa...32&mid=6337
    Some of the Pipes developers have also worked on YQL. so maybe they will provide more detail.

    QUOTE (Alexander Skwar @ Apr 9 2009, 11:07 AM) <{POST_SNAPBACK}>
    Hm, yes, maybe.

    Do you know, if there are any usage limits for Yahoo! Pipes?
    0
  • hapdaniel,

    thanks a lot!

    Actually, it seems that I can get exactly what I want with a pipe. I just need to pass on a date and Yahoo! Pipes is clever enough to figure out the date from the string given (something like "Thu, 09 Apr 2009 21:32:54 +0200") and then I can have the pipe filter out all the too-old entries.

    BUT: I just now read http://discuss.pipes.yahoo.com/Message_Boa...frt=2&off=1, which you've linked, and I guess pipes won't be the way to go then. I guess, I need to use YQL or something I develop completely on my own.

    All right - as Pipes is a dead end, what would be the easiest way to sort a feed on item.pubDate using YQL? It should do a proper sort, interpreting pubDate as a date.

    Oh! BTW: Sam is not correct. Doing a "| sort(field='pubDate')", YQL does *NOT* sort just lexically. Instead, pubDate is interpreted as a date! See → http://developer.yahoo.com/yql/console/?q=...D%27pubDate%27)

    CODE
    [...]
    <item>
    <pubDate>Fri, 27 Feb 2009 14:59:34 +0000</pubDate>
    </item>
    <item>
    <pubDate>Sun, 01 Mar 2009 11:27:15 +0000</pubDate>
    </item>
    <item>
    <pubDate>Mon, 09 Mar 2009 15:33:26 +0000</pubDate>
    </item>
    <item>
    <pubDate>Fri, 13 Mar 2009 07:27:45 +0000</pubDate>
    </item>
    [...]


    As you can see, the feed is sorted on the date value of pubDate and not just alphabetically. If it would've been sorted alphabetically, the "Fri," Friday entries would be together. But they aren't!

    Great! So YQL is the way to go then - if now only someone could explain the usage limits :lAlexander
    0

Recent Posts

in YQL