Is it possible to alphabetize the results of mt:searchresults?
Right now I use the MT tag function and search to display my recipe index here:
http://www.elise.com/recipes/subject-index.php
When you click on any of these tags however (take http://www.elise.com/recipes/tag/Chicken%20Breasts for example) the results are in order of when they first appeared on the blog, most recent first, rather than alpha.
It would make a lot more sense for the results to be in alpha order.
Possible?
Reported on Movable Type 4.2

What should the list of Entries tagged with Chicken Breasts be ordered by, if not by authored_on date? You say alpha (meaning alphabetically I guess) but what field/criteria do you want to order by? Entry title?
Yes, alphabetized by title. As if it were the index in a cookbook.
Yes that's possible.
1. you could create 26 mt:If blocks each asking if EntryTitle starts with a given letter like="ˆ(A|a)", thus permitting only those Entries to pass that start with the given letter.
2. Use mt:EntryIfTagged 26 times. This would require you to tag each Entry first, for example: @a, @b, or @alpha-a, @alpha-b, etc..
3. Create an Entry template with an archive mapping that publishes entries to folders /a, /b, /c etc. based on your input into a custom field on the Edit Entry screen. Then try to create a loop with the mt:Folders tag .... all right. I'll stop here. This leads nowhere.
Hm, what else...
Hmm. Number 1 seems doable, though it seem like it might slow down the rendering of the results. It's also rather clunky.
There should be an attribute for the result listing.
Clunky, and trying way too hard, primarily by sticking with the core tags. And yes, there will be major impact on rendering time.
Have you tried the Order plugin(as the sort's simple) or Collate? The search system is always a little weird, but assuming that doesn't come into play, Order will make this trivial.
Also a sort attribute is entirely reasonable for search results. File a feature request?
Hi Su, just tried the Order plugin. Couldn't get it to do anything, but that could be because I don't really know how to implement the code properly in to mt:searchresults code. Really wish plugin authors would explain their examples better. I'll have Jesse take a look at it next week. Thanks!
Given that a sort attribute is an entirely reasonable thing for search results, I was hoping that it was already in there somewhere. I'm sure someone has filed this as a feature request years ago, but can do so again. Thanks again!
Hi, Elise, trhis issue did come up in the old forums in 2006: Search Titles Only And Alphabetize Search Results, in the next to last post, by elf#3:
Creating a Search Form -- the 3.2 docs page the poster references -- says,
From the old docs,
It sounds doable, if you can change option values.
Hello shenews,
Bingo, thank you! The following configuration directives worked!
SearchSortBy title
ResultDisplay ascend
You have to include the "ResultDisplay ascend" or the "SearchSortBy title" will not work.
Now http://www.elise.com/recipes/tag/Chicken%20Breasts is in alphabetical order.
The downside of this technique for those who might be interested in it is that it affects all search results on your MT install, not just the specific instance of one search result. In my case, it doesn't matter as I use Google search for almost all other searches on the site, and in the case that I do use mt search, I want the results listed by title.
The upside is that it is the easiest thing in the world to implement. No plugins. No messing with code on templates.
Excellent!
I wonder if it could be restricted for use on just a specific blog and/or tag. Something like
<select name="SearchSortBy">
<mt:IfTagSearch tag="Chicken">
<option value="title">Title</option>
<mt:Else>
<option value="created_on">Authored On Date</option>
</mt:IfTagSearch>
and the same for the sort order. (Not sure about syntax, if you'd need to use an mt:If tag="Chicken" and the same kind of conditional for "Include blogs" or if you can change that part of the form at all.)
I've been a frequent visitor to your recipes, btw. Great cooking blog.
Hmm. Good question. In any case the code works for my site as is, so no more messin' with it for me! Thanks again.