0

I'm sorry if this is not the correct community to ask this question, if not please suggest a transfer.

I'm compiling an index of sorts for a large songbook where all the titles and first lines of the songs (if not identical) are listed. However I'm running into a dilemma on how to treat spaces and commas.

The automated sorting will treat a space or a comma like it is a letter occurring before the "A", as follows:

A child of the King
A Father over yonder
Abba, Father
Across the bridge

My personal intuition would be to ignore spaces and punctuation when looking something up, so I would expect the correct sorting to be:

Abba, Father
A child of the King
Across the bridge
A Father over yonder

Is my expectation wrong or is it the sorting algorithm that needs revision? For now I've resorted to creating double entries so it would be found either way.

A child of the King
A Father over yonder
Abba, Father
A child of the King
Across the bridge
A Father over yonder

A related question is how to deal with abbreviations (if that's not the correct term, please forgive my jargon ignorance)

‘t Was a day in early spring time

I'm currently listing it 3 times under I, T and W, in order to make the index "fool proof". I can imagine plausible reasons for all three approaches (literal, actual or ignore "noise words"). Combine that with the spaces-rules and we have 6 entries for this phrase. In English this does not occur that often, but in Dutch it occurs frequently.

A third (less related) question is whether to list numbers before or after letters, and would it matter if they are Arabic or Roman numerals?

I was wondering if there are any official conventions?

3
  • 1
    If you ignore ie remove whitespace or punctuation, you must still somehow do tie-breaking between phrases that are different but reduce to the same string. – Adam Bittlingmayer Oct 20 '19 at 18:34
  • @AdamBittlingmayer true, in that case I list them in the order they appear in the book. By now I've dropped the double entries with spaces and reverted to just ignoring non alphanumeric characters. A smaller index also helps find stuff faster. – Louis Somers Oct 22 '19 at 1:13
  • 2
    preparation of indices is on-topic on TeX - LaTeX – jk - Reinstate Monica Oct 22 '19 at 12:09
2

The general standard for sorting phrases in English ignores case, and puts \0 before  before A. In other words, a comes before a b comes before aa.

At a quick check, this is used by the American Heritage Dictionary and Wiktionary, and I think the OED as well; I certainly can't think of any dictionary that would sort aa before a b. In the pre-computer days, this algorithm was specified as something like "sort phrases word by word; sort words letter by letter; break ties by length": the first word in a b comes before the first word in aa, so the whole phrase comes first.

1
  • Thanks, I guess I should adopt these rules after all. The way I sorted them (ignoring any non alphanumeric characters) turned out to be confusing for someone else reviewing my work. – Louis Somers Oct 22 '19 at 23:35
4

I don't know that there is a standard -- there could be one. I would favor using the default sorting algorithm, on the grounds that this is what users who look things up a lot will be most familiar with.

Donald Knuth's Searching and Sorting is available on line.

5
  • It looks like the algorithm is using the ASCII table as a standard with the exception that it ignores uppercase (or internally converts everything to lowercase). I don't expect most users to know that space comes before A or that accent grave and backslash \ come after Z. If there is no standard I'll revert to ignoring any non-alphanumeric characters. Thanks for your thoughts any way, there don't seem to be any strong opinions on the matter. Most dictionaries list words instead of phrases so I guess this is a rare edge case. – Louis Somers Oct 22 '19 at 1:33
  • Wiktionary has phrases, how does it sort? – Adam Bittlingmayer Oct 22 '19 at 8:04
  • I imagine you know this, but the order that is required is defined with respect to a "sort handle", which is derived by using a copy of the entry modified so as to remove those features which are to be ignored. For instance, lower case will all be replaced by upper case letters and any strings of white space characters (spaces and tabs) will be replaced by single space characters, perhaps articles will be removed. I do not think ignoring non-alphanumeric characters is a very good idea -- "a part" should not be ordered like "apart". – Greg Lee Oct 22 '19 at 8:17
  • 1
    I added a reference to my answer. – Greg Lee Oct 22 '19 at 8:42
  • @GregLee that's funny, I actually own the physical book! I found a reference to some standards on page 5 exercise 17 (American Library Association rules for filing Catalog Cards, Chicago 1942). – Louis Somers Oct 22 '19 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.