LT Sort Author Works

DiscussãoHacking LibraryThing

Aderi ao LibraryThing para poder publicar.

LT Sort Author Works

Este tópico está presentemente marcado como "adormecido"—a última mensagem tem mais de 90 dias. Pode acordar o tópico publicando uma resposta.

Editado: Fev 3, 2013, 12:54am

Adds "sort by copies" and "sort by title" links to the works headers on author pages. These let you resort the works on the fly.

Note that if you're on an author page where some works are hidden behind a "show all" link, it will only sort the visible works. Click on the "show all" link and then sort.

Fev 2, 2013, 11:49pm does it work?
What are the steps?

I clicked the install button, but it just showed me your script...

Fev 3, 2013, 12:09am

Here's a good starting point:

Let me know if it still leaves some questions unanswered.

Fev 3, 2013, 12:42am

Ok, I installed Greasemonkey, installed the script, and went to an author's page. Greasemonkey shows a little "check" next to the LibraryThing script, but I don't see anything that allows me to sort works by popularity or title. Where should I be looking for it?

Fev 3, 2013, 12:55am

I added a couple of screenshots to the initial post.

Fev 3, 2013, 3:52am

brightcopy, you are a genius. Thank you very, very much.

Editado: Fev 3, 2013, 5:16am

It only worked for me one time, though. Now it doesn't appear even though I closed FF and reopened. I will reboot.
Nope, that didn't do it.

Fev 3, 2013, 8:22am

Brightcopy, thank you. Works perfectly.

Fev 3, 2013, 1:58pm

Doesn't look like that on mine. It still looks like it used to look. Greasemonkey says the script is running.

Fev 3, 2013, 6:19pm

For those having problems - give me an example author url. Also, try
and tell me if it works on one, both or neither.

Fev 3, 2013, 6:34pm

It works for me on some author pages but not others. I do not see the sorting links on either of the Stephen King pages. I do see them on the William Shakespeare pages:

I can find other examples of working and not working if that would be useful.

Editado: Fev 3, 2013, 7:01pm

Works on both King pages, neither Shakespeare pages. Edit: It showed up on the Shakespeare pages if I let the page sit a minute or so.
Other pages I tried it on and saw it didn't work:

Pages I tried where it does work:

Edit: Something I noticed...all the author pages work fine if I go to them from my library (I look in my library and select their name from there). They do NOT work if I do a "search site" of the author's name and look at it from there.

Fev 4, 2013, 1:59am

I think I see some of the problems. Thanks, everyone, I''ll upload a fix when I get a chance.

Fev 6, 2013, 10:28pm

Okay, I think that does the trick. The main problem was between authors that are in your catalog versus those you have no works from.

Update your script and test it out and let me know how it goes. For those new to the whole thing, you can just go to the script page at the very top and click the green Install button.

(But not the stupid green "Download" button.)

Fev 7, 2013, 4:30pm

Perfect. Thank you so much for this long-desired solution! :D

Fev 7, 2013, 4:45pm

I do so love you and your scripts. hahaha. I never even bother trying to look at stuff on author pages because it's ridiculous, you can't find anything with prolific authors! This is awesome.

Editado: Fev 8, 2013, 9:15am

Glad to help! For whatever reason, this one piqued my interest.

One oddity is that it'll promote weird "No title" works to the top. Like this one (please don't "fix" it, though - I'm going to file a bug report):

Sort by title and the first one is "No title". This is a side effect of the title being blank even though the link text is "No title". I sort by the link's title.

The odd part is that it should have a title. That book is this one:

Weird, huh? Like I said, time for a bug report. I posted about a similar one when fixing an entry like this on Stephen King (see the All Hail King Stephen thread in Talk About LibraryThing).

Editado: Fev 8, 2013, 9:44am

Aww, I just discovered for some reason the script doesn't work on my laptop, boooo. :( lol.

(also I have no idea what's up with that title. I tried looking for others that have only copies of the work title in Greek text, but they seem to be fine, so I'm out of ideas lol)

Fev 8, 2013, 10:02am

Is your laptop running the same browser and the same version? And which would that be?

Fev 8, 2013, 12:05pm

No, it's old, lol. I'm on a super outdated Ubuntu, running Fx 3.6.11 haha. But all your other scripts work fine! heh

Fev 8, 2013, 3:11pm

Ah, that'd be .outerHTML()s doing, I'm afraid. I could code around it if you need to, but it was the easiest way and only requires FF 11. Can't you update? Lots of security holes there, I'm sure.

Fev 9, 2013, 6:43am

Not really, due to the super outdated Ubuntu, lol. That's okay though, it works on my desktop, and eventually I'll update/upgrade the laptop to a new (and current lol) flavor of Linux. :P

Mar 14, 2013, 4:30pm

I don't want to appear to be complaining, because this is one of the best improvements to LT in a very long time. It is such a huge help.

However, I would request some tweaking to the alphabetization rules that the script encompasses. It doesn't alphabetize like the rest of LT does; for instance titles that begin with "A ....." or "The ....." are lumped together. It also separates capitalized titles from non-capitalized titles, which is kind of helpful in a way, but probably not optimal. (how it even does that is far, far beyond me)
My example today is

So, many thanks once again, brightcopy.

Mar 14, 2013, 5:20pm

It's actually harder to mix capitalized and non-capitalized - in straight ASCII and most codes based on/related to it, all the capitals come first and then all the non-capitals, so an ASCII-order sort (which is the simplest one) will do that separation.

Don't know if it would be possible to do an LT-style sort - there's a lot of code in there for ignoring A and The and the like.

Mar 14, 2013, 9:20pm


Well, adding the -i flag or using tolower() isn't exactly hard. But yeah, it's not as though omitting it is at all mystifying.

Just excluding leading "The, A, An" would be easy enough to do - that's a one-line regexp. LT's proper sorting is harder.

Mar 14, 2013, 9:40pm

It would be fairly easy to do a case-insensitive search. All I'd have to do is do a lowercase() of the two values when I compare them. It doesn't affect the value, just the comparison basis.

I thought about doing some more fancy, and yeah the A/An/The would be low-hanging fruit. I also found that there's a locale-sensitive lowercase that might be nice for people using other languages. But of course it won't do any good if you have some books from several languages.

Abr 8, 2013, 11:05pm

Finally got a chance to look at this again now that my cover nav script is finished. I think I got all the requests and more:

Sort by title will use a locale-sensitive sort (meaning it takes the language of your computer into account - though not necessarily the language of the individual books).

Sorting will also attempt to intelligently sort numbers so "Abc 99 Def" comes before "Abc 1000 Def".

By default, the sort will ignore the first word if it is "a", "an" or "the". You can edit this list of words by choosing "Leading title words to ignore" from the script menu.

Just use your browser's built in updating if it has it (in google there is a "check for userscript updates" option, in Firefox you have to find the script under Tools->Addons->User scripts, right-click on it and choose "Find updates"). If it doesn't or that doesn't work, just go to the script page at the top of message #1 and click the green Install button at the top right of the page (beware of advertisements that have "download" or "install" buttons that aren't at the top right).

Abr 9, 2013, 11:13am

By default, the sort will ignore the first word if it is "a", "an" or "the". You can edit this list of words by choosing "Leading title words to ignore" from the script menu.

This will cause A is for Alibi to sort to the wrong location and there may be some mixed language libraries for which this won't work well. But you probably knew that already.

Abr 9, 2013, 11:16am

#28 by jjwilson61> Yep. Until we get some sort of real artificial intelligence, you can't have it both ways.

Abr 9, 2013, 11:27am

LibraryThing uses || to indicate the sort point in a title, e.g. "||A is for Alibi" should sort with the As. Whether that shows up in the data you're looking at I don't know. I also don't know how well known it is, or how often it's used. I'm not sure what I do know, sometimes.

Abr 9, 2013, 11:30am

brightcopy, this is GREAT. How many times did I wish for this while doing some of my 22K combinations!


Editado: Abr 9, 2013, 11:36am

#30 by r.orrison> Nope. :) What you see is what I get.

#31 by LolaWalser> You're quite welcome!

I have more scripts up my sleeve. Hopefully now that I'm done with the giant cover navigation one I can get a few more smaller ones banged out.