<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -26,11 +26,18 @@ class TagSearchPage &lt; Page
     end
   end
 
-  desc %{    Renders the contained block for each result page.  The context
-    inside the tag refers to the found page.}
+  desc %{    &lt;r:search:results:each [sort_by=&quot;id&quot;] [order=&quot;asc&quot;]/&gt;
+    Renders the contained block for each result page.  The context
+    inside the tag refers to the found page. The optional sort_by and order attributes
+    specify how the results are sorted}
   tag 'search:results:each' do |tag|
+    # Ordering in Ruby because we already fetched our resultset before
+    tags = found_tags
+    tags = tags.sort_by(&amp;tag.attr['sort_by'].to_sym)  if tag.attr['sort_by']
+    tags = tags.reverse                               if tag.attr['order'].to_s =~ /desc/i
+    
     returning String.new do |content|
-      found_tags.each do |page|
+      tags.each do |page|
         tag.locals.page = page
         content &lt;&lt; tag.expand
       end</diff>
      <filename>app/models/tag_search_page.rb</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,7 @@ display_tags_part:
     &lt;r:search:results&gt;
       &lt;h2&gt;These pages are tagged with &quot;&lt;r:search:query/&gt;&quot;.&lt;/h2&gt;
       &lt;ul&gt;
-        &lt;r:search:results:each&gt;
+        &lt;r:search:results:each order=&quot;desc&quot; by=&quot;published_at&quot;&gt;
           &lt;li&gt;&lt;r:link/&gt; door &lt;r:author/&gt; op &lt;r:date/&gt;&lt;/li&gt;
         &lt;/r:search:results:each&gt;
       &lt;/ul&gt;</diff>
      <filename>test/fixtures/page_parts.yml</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,7 @@ documentation:
   slug: documentation
   status_id: 100
   parent_id: 1
-  published_at: 2006-01-30 08:41:07 
+  published_at: 2006-01-31 08:41:07 
 books:
   id: 3
   title: Books</diff>
      <filename>test/fixtures/pages.yml</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,12 @@ class TagSearchPageTest &lt; Test::Unit::TestCase
     assert_match /Documentation/, output
   end
   
+  def test_resulting_pages_should_be_sorted
+    @page.request.request_parameters = {:tag =&gt; &quot;lorem&quot;}
+    output = @page.render
+    assert_match /Documentation.*Ruby Home Page/, output
+  end
+  
   def test_unknown_tag_should_say_so
     @page.request.request_parameters = {:tag =&gt; &quot;foobarbar&quot;}
     output = @page.render</diff>
      <filename>test/functional/tag_search_page_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cde11bf303bcce5dc24a2834dc70afe90a617f4f</id>
    </parent>
  </parents>
  <author>
    <name>Jan De Poorter</name>
    <email>jan@defv.be</email>
  </author>
  <url>http://github.com/jomz/radiant-tags-extension/commit/cad1684b4102d61ee3cdecfc3aae64ba58e35568</url>
  <id>cad1684b4102d61ee3cdecfc3aae64ba58e35568</id>
  <committed-date>2009-06-10T08:33:59-07:00</committed-date>
  <authored-date>2009-06-10T08:32:38-07:00</authored-date>
  <message>Add attributes to sort the pages</message>
  <tree>ef0b183721da3dd29ce742076cf01274f76b482e</tree>
  <committer>
    <name>Jan De Poorter</name>
    <email>jan@defv.be</email>
  </committer>
</commit>
