Where I work, we have started a page for "new people" in the department. People are added to the page as they join the group. Each person has a section for mini-bio and other information and there is a table of contents.
The problem: as the page gets larger, it's more difficult to find the entry for a given person. The TOC is ordered by when the person joined. It would be convenient to be able to sort the TOC alphabetically (it's just a list after all)
I started looking for ways to sort a list in TWiki. As long as I was at it, I figured I might as well look for a generalizable solution that can sort any bullet list.
I looked at Plugins.SpreadSheetPlugin but the sort functions want table cells. No tables here.
I figured JavaScript could solve the problem. I did a web search for JavaScript that sorts lists and found a very promising script written by Bruno Bornsztein (blog.feedmarker.com). The script worked well on simple bullet lists but needed some work to modify it for a TOC.
In particular, the script was finding the list by ID and TWiki TOCs don't have a unique ID :-( However, they do have a unique class :-) (providing, of course, that there is only one TOC on the page!)
I modified the JS to handle classes (using the named class to set an id on the list in question) and got it working. Then I handed it to Main.RichMorin for review and he said: you should put in a way to revert to the original order.
Well, duh. That was a bit trickier. I could just reload the page - but that's time consuming and would revert every list on the page.
So I asked around, got some help, and learned a few new JS tricks, and now lists are revertible to initial order as well as sortable in either ascending or descending order.