Copy link to clipboard
Copied
Hello,
Is anyone aware of a script that will sort a list of Bible references into the order the books appear in the Bible (i.e., beginning with Genesis)? Each reference is in its own paragraph, beginning with the name of the book.
If there isn’t a specific script for that, a script where you can map a list to a sort number and do the sort that way would also be great (e.g., Genesis = 1, Exodus = 2, and so on).
Thank you.
This is funny. I was just working on that solution.
It might be clunky and have potential issues but this is it so far:
Copy link to clipboard
Copied
The pre-installed sample Sort Paragraphs script could probably be reconfigured to handle your use case, but it would take some lifting. In its base form it only sorts alphabetically, but I would start there.
Copy link to clipboard
Copied
Can you post a snippet of sample text, as it appears now and how you'd like to have it sorted?
Would you run such a script on an entire document, or on a selected story or text frame, or only in a selected text?
Copy link to clipboard
Copied
Thank you for your response, _Jongware_. Optimally the script would run on selected text, but the target text could certainly be pulled out and run in a separate document or in a frame at the end of the document. The situation is scripture references in an index, typically about four hundred references. Here's a sample list sorted alphabetically, followed by the same list in Bible order, followed by a list of the Bible books with sort numbers.
List 1
1 Chronicles 1:13–16
1 Corinthians 11:17–34
1 Kings 14:21
1 Samuel 1:20
1 Thessalonians 4:16
1 Timothy 5:1–2
2 Chronicles 33:7
2 Corinthians 12:2
2 John verse 13
2 Kings 18:9–19:36
2 Samuel 1:24
Acts 1:15–20
Amos 5:18–27
Colossians 2:9
Daniel 10:5–7
Deuteronomy 1:37
Ecclesiastes 3:19
Ephesians 2:8–9
Exodus 12:1–28
Ezekiel 48:28
Ezra 2:63
Genesis 1
Hebrews 2:14–15
Hosea 1–3
Isaiah 10:24–34
James 1:6
Jeremiah 47:1, 2, 4
Job 19:25–27
Joel 2:1–11
John 1:14
Joshua 10
Jude verse 12
Judges 11:1–12:40
Lamentations 4:20
Leviticus 1–7
Luke 1:80
Mark 1:14, 15
Matthew 1:1–17
Micah 5:2
Nehemiah 7:65
Numbers 1:50, 53
Philemon verses 7, 20
Philippians 2:14–15
Psalms 109:6–8
Revelation 1:17
Romans 16:1
Ruth 4:11
Tobit 12:15
Zechariah 12:10
List 2
Genesis 1
Exodus 12:1–28
Leviticus 1–7
Numbers 1:50, 53
Deuteronomy 1:37
Joshua 10
Judges 11:1–12:40
Ruth 4:11
1 Samuel 1:20
2 Samuel 1:24
1 Kings 14:21
2 Kings 18:9–19:36
1 Chronicles 1:13–16
2 Chronicles 33:7
Ezra 2:63
Nehemiah 7:65
Job 19:25–27
Psalms 109:6–8
Ecclesiastes 3:19
Isaiah 10:24–34
Jeremiah 47:1, 2, 4
Lamentations 4:20
Ezekiel 48:28
Daniel 10:5–7
Hosea 1–3
Joel 2:1–11
Amos 5:18–27
Micah 5:2
Zechariah 12:10
Tobit 12:15
Matthew 1:1–17
Mark 1:14, 15
Luke 1:80
John 1:14
Acts 1:15–20
Romans 16:1
1 Corinthians 11:17–34
2 Corinthians 12:2
Ephesians 2:8–9
Philippians 2:14–15
Colossians 2:9
1 Thessalonians 4:16
1 Timothy 5:1–2
Philemon verses 7, 20
Hebrews 2:14–15
James 1:6
2 John verse 13
Jude verse 12
Revelation 1:17
List 3
Copy link to clipboard
Copied
Here are two short lists that might give a better idea. The first is in alphabetical order and the second is in the order the books appear in the Bible.
List 1
Deuteronomy 1:37
Exodus 12:1–28
Genesis 1
Joshua 10
Judges 11:1–12:40
Leviticus 1–7
Numbers 1:50, 53
Ruth 4:11
List 2
Genesis 1
Exodus 12:1–28
Leviticus 1–7
Numbers 1:50, 53
Deuteronomy 1:37
Joshua 10
Judges 11:1–12:40
Ruth 4:11
Copy link to clipboard
Copied
You'll certainly have to add some sort key because there is no way that the book order is predictable. A custom script with the book order hard coded is possible, but that's not straightforward.
One possibility is to add sort keys at the beginning of the entries. The keys can be numbers or letters. If you use numbers, use double-digit numbers if the number of books is larger than 9 (as you see I've no idea about the bible). You can leave the keys in place for future sorts if you want: apply a character style to them that hides them (apply 0.1 points type size, 1% horizontal scale, paper colour).
To sort the list you can use the script that Brian mentioned, but it is very slow. A quicker script is here:
Copy link to clipboard
Copied
This is funny. I was just working on that solution.
It might be clunky and have potential issues but this is it so far:
edit: added ^ to grep replace
Copy link to clipboard
Copied
Wow, that works perfectly! Thank you so much. This is going to be a real time saver. I am very grateful!
Copy link to clipboard
Copied
I am glad to hear that.
I have not tested it in too many scenarios yet. I suspect there will be issues along the way.
Please use at your own risk.
Copy link to clipboard
Copied
Basically your script works great. Thanks for that. Unfortunately, some of the formatting of the text has been shifted. Do you have an idea what could be the reason for that?
Copy link to clipboard
Copied
As is just have seen the numbers do not seem to be correctly taken into account in the sorting process. In this respect the script is unfortunately useless
Copy link to clipboard
Copied
Well, not quite, as a turnaround InDesign's Sortparagraph-Script can be used to sort the individual sections to the end. Thanks anyway!
Copy link to clipboard
Copied
Yeah, the script currently does not take into account the possibility of multiple text styles per paragraph.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This script is awesome, thanks SO much! I'm using it for sorting a Scripture index which has headings with the name of the book, and then the index, like so:
Genesis
Genesis 1
Genesis 2
Exodus
Exodus 5
Exodus 6
Unfortunately, this script separates the headings from the entries (which have numbers after them). 😞 😞 So after sorting, all the headings have been sorted separately at the beginning of the index, and then the entries were sorted separately after that. Is there any way to modify the script so that it leaves the heading without a number as the first, and then lists all other entries after it?
Copy link to clipboard
Copied
I figured out a simple solution to this problem. I just added "00" to the headers so that they'd show up before any of the other chapters. 🙂
Copy link to clipboard
Copied
Great that you found a solution. 🙂
Copy link to clipboard
Copied
Yeah, why didn't I think of that solution first thing? 🙂 It's crazy how the simplest solution sometimes takes a while to "hit" home. Did you see my post about the more serious sorting issue though? I'm hoping there's a simple solution for that one too, but it hasn't come to me yet.
Copy link to clipboard
Copied
Could you please show me a full example of this being invoked and sorting a short list of references? This is just what I need, but I do not know how to use it.
Thanx in advance for all you do to help others.
Bob D.
Copy link to clipboard
Copied
Sorry for being such a newbie, but could anyone show me a full example of this being invoked and sorting a short list of references? This is just what I need, but I do not know how to use it.
Thanx in advance for all you do to help others.
Bob D.
Copy link to clipboard
Copied
As outlined in the other post, the simplest method is to add leading zeros to numbers so that they're all the same length. Do two find-change queries:
The first one adds two zeros to single-digit numbers:
Find what: \b(\d)\b
Change to: 00$1
The the second query adds a single zero to double-digit numbers:
Find what: \b(\d\d)\b
Change to: 0$1
Now sort your index. Then remove the leading zeros in one query:
Find what: 0+\d
Change to: <leave empty>
P.
Copy link to clipboard
Copied
I need it often because I typeset many Christian (Evangellical, Theological) books, but in German. But in German the order of the epistles is different and (this is not relevant here) the number of chapters and verses in the old testament and in Acts are different than in English, only messianic Bibles (like CJB) have the same chapter number and verse numbers.
Copy link to clipboard
Copied
If you want it to work with German Bibles you have to change the contents of the bookList array to the correct German book names.
I know the chapter/verse can differ from translation to translation but as long as you put in the correct bookList that should not matter.
Feel free to modify as you please.