Blogger Hack: Alphabetizing Entry Index

This code will take all the entries on the page and list them in alphabetical order, creating an index. This can be useful, for example, if your blog is a series of book/movie reviews, and you title your entries with the title of the books/movies. It’s less important to the reader, in this instance, what date the review was posted on than the subject of the review.

It is based upon the code Blogger has on its help pages to list the archive links on the main page in reverse chronological order.

Place the code in the sidebar of your template, using <MainOrArchivePage>, <ArchivePage>, or <MainPage> tags to indicate which pages you want indexed.

Here is the code:

<ul class=”archive-list”>
<script type=”text/javascript”> 

var archives = new Array();

function mysortfn(a,b) {
if (a[1]<b[1]) return -1;
if (a[1]>b[1]) return 1;
return 0;

archives[archives.length] = new Array(‘<$BlogItemNumber$>’, ‘<$BlogItemTitle$>’);


for (var i=0;i<=archives.length-1;i++)
document.write(‘<li><a href=”’ + archives[i][0] + ‘”>’ + archives[i][1] + ‘</a></li>’);


An example of the results of this code can be viewed at comicspoilers

5 thoughts on “Blogger Hack: Alphabetizing Entry Index

  1. John

    It works for any page…the main index page, or single archive pages, but it won’t create a listing of multiple archive pages.

  2. John

    If you want to place it on just your index page enclose the code within <MainPage> and </MainPage> tags.

    If you want it just on your archive pages enclose the code between <ArchivePage> and </ArchivePage> tags.

    If you want it on both, enclose the code between <MainOrArchivePage> and </MainOrArchivePage> tags.

  3. Amit

    Hi John,

    Thanks for this hack, which will be useful to me. I was wondering if there is a way to show titles with a certain tag. For example, I may have movie and book reviews, and I would like to have two drop-down lists – one for movies, and one for books. How would I include the titles with a particular label? label = “book review”, or label = “movie review”)

    Thanks a lot!


  4. Wade

    I would really appreciate it if you could tell me what the first two or three lines of code in the New Blogger template to search for that this needs to go after. I have done some HTML but the code in the templates on Blogger is greek to me.

Comments are closed.