FeedForAll Forum Index  
 Home  •  FAQ  •   Search   •  Register   •  Profile   •  Log in
 Reversing the PubDate sort order..... View next topic
View previous topic
Post new topicReply to topic
Author Message
bobby13



Joined: 15 Mar 2009
Posts: 5

PostPosted: Sun Mar 15, 2009 11:24 am Reply with quoteBack to top

I would like to reverse the order so the oldest pub dates appear first. Possible? I found the following code in rssmesh.php that *seems* needs to be modified but I'm pretty much clueless with php...


Code:
    if ($sortOutputByPubDate) {
      // Sort by PubDate
      for ($x = 0; $x < count($rss_parserResults->Items)-1; $x++) {
        for ($y = $x+1; $y < count($rss_parserResults->Items); $y++) {
          if ($rss_parserResults->Items[$x]->pubDate_t < $rss_parserResults->Items[$y]->pubDate_t) {
            // Swap them
            $swapTemp = $rss_parserResults->Items[$x]; $rss_parserResults->Items[$x] = $rss_parserResults->Items[$y]; $rss_parserResults->Items[$y] = $swapTemp;
          }
        }
      }
    }


Thanks in advance for any help!
View user's profile
bobby13



Joined: 15 Mar 2009
Posts: 5

PostPosted: Sun Mar 15, 2009 1:37 pm Reply with quoteBack to top

Hmmmmm... been playing with it. Commwnted out the following line....

Code:
            $swapTemp = $rss_parserResults->Items[$x]; $rss_parserResults->Items[$x] = $rss_parserResults->Items[$y];


Seems to be working ok.

Look kosher?
View user's profile
bobby13



Joined: 15 Mar 2009
Posts: 5

PostPosted: Sun Mar 15, 2009 2:00 pm Reply with quoteBack to top

Never mind, that's not working right. :-(
View user's profile
bobby13



Joined: 15 Mar 2009
Posts: 5

PostPosted: Sat Apr 18, 2009 8:24 am Reply with quoteBack to top

Can anyone help me with this? Pretty please?
View user's profile
MacSupport



Joined: 24 Feb 2005
Posts: 2805

PostPosted: Mon Apr 20, 2009 3:56 pm Reply with quoteBack to top

bobby13 wrote:
I would like to reverse the order so the oldest pub dates appear first. Possible? I found the following code in rssmesh.php that *seems* needs to be modified but I'm pretty much clueless with php...


Code:
    if ($sortOutputByPubDate) {
      // Sort by PubDate
      for ($x = 0; $x < count($rss_parserResults->Items)-1; $x++) {
        for ($y = $x+1; $y < count($rss_parserResults->Items); $y++) {
          if ($rss_parserResults->Items[$x]->pubDate_t < $rss_parserResults->Items[$y]->pubDate_t) {
            // Swap them
            $swapTemp = $rss_parserResults->Items[$x]; $rss_parserResults->Items[$x] = $rss_parserResults->Items[$y]; $rss_parserResults->Items[$y] = $swapTemp;
          }
        }
      }
    }


Thanks in advance for any help!


Bobby13,

You were very close. You need to change the comparison

Code:

if ($rss_parserResults->Items[$x]->pubDate_t > $rss_parserResults->Items[$y]->pubDate_t) {


That should do the trick.

Jim

_________________
Be sure to check out the FeedForAll Mac tutorials at: http://www.FeedForAll.com/tutorials/

FeedForAll Mac and rss2html.php
support@FeedForAll.com
View user's profileVisit poster's website
bobby13



Joined: 15 Mar 2009
Posts: 5

PostPosted: Wed Apr 22, 2009 7:28 pm Reply with quoteBack to top

Thanks Jim! I'll give it a shot in the next few days and post back.
View user's profile
Display posts from previous:      
Post new topicReply to topic


 Jump to:   



View next topic
View previous topic


Powered by phpBB © 2001, 2002 phpBB Group :: FI Theme