Hi Christopher,

Since the document <emit> only gives you pointers to the files you cannot sort 
directly on the titles or whatever property you need. (You can sort on the path 
itself with the generic emit sort capability, i.e. sort="ref", but that's not 
very useful.)

Instead you need to place the results in a temporary data structure that you 
can sort (e.g. a mapping with titles as keys) and loop through that.

  <set variable="var.fileinfo" type="mapping"/>
  <emit source="category" file="..." node="..." document="">
    <!-- Get file info and place in mapping -->
    <emit source="dir" ...>
      <set variable="var.fileinfo.&_.title;" type="text/*">
        <a href="...">...</a>
      </set>
    </emit>
  </emit>
  
  <!-- Output file info entries sorted on keys -->
  <emit source="values" variable="var.fileinfo" sort="index">
    &_.value:none;
  </emit>

(Note that this example doesn't cope with empty titles since the key isn't 
unique then. One workaround is to build a composite key like 
"&_.title;|&_.path;" to ensure uniqueness and still get the titles in 
alphabetical order when possible.)

Cheers,

-- Jonas

Reply via email to