in reply to Twisted sort requirements

other monks have already suggested ways to do the "twisted sort", but have you considered just changing your data structures on the first place?

You are storing in the same array two kinds of unrelated information: a list of books and author ordering information. Using a magic marker is a bad idea almost every time.

In that case, the obvious data structures to use are an array to store book descriptions and a hash to store author ordering information.

If you are getting the information from a DB, the information should already be structured that way there. You should even be able to get the list of books ordered from the database!

If you are reading the information from a file (or from the network) you can build those two structures on the fly on the parsing phase with almost identical effort and then other parts of your code will become much cleaner.