I think Neil has the right idea. This works for me but it isn't real elegant. 
One problem is that it sorts by the first name of the author rather than the 
last. The dates work fine as long as they are all in the same format.

First change all the returns in each record to a tab by entering these patterns 
into the find dialog box and doing replace all.

Find: (?<=\S)\n(?=\S)
Replace: \t

Then you can run the sort command using sub-patterns so the desired fields are 
used. Select All in the document and then select Text > Sort Lines... and use 
these settings.

Sort using pattern: ^Annotation[\s\S]+?Created at: (.*?)[\n\t]Author: 
(.*?)[\n\t][\s\S]+?$
Specific sub-patterns: \2\1

Strip off the whitespace at the top of the document. Then replace \n with \n\n 
to restore the space between records and replace \t with \n to change the tabs 
back into returns.

[fletcher]

> On Nov 4, 2024, at 8:35 AM, Howard <[email protected]> wrote:
> 
> I have multiple records in a text file in the format below (seven sample 
> records shown). I want to sort all of them by Author and then, within Author, 
> Created At. In a record, the first four lines are always just one line; 
> however, the fifth line (Comment) can be up to 30-40 lines, possibly more).
> 
> Is this something that BBEdit can do? If it is, how can I do it?
> 
> Howard
> ______________________________________________________________________________
> 
> Annotation 1:
> Created at: 2024-10-30 08:02
> Author: Arthur Antique
> Type: Reply
> Comment: Lorem ipsum odor amet, consectetuer adipiscing elit. Quisque fusce 
> placerat rutrum fusce; purus mollis nulla lobortis. Vivamus faucibus mi 
> neque; a pretium elementum ut suscipit rutrum. Enim sapien et rutrum dictum 
> elit habitasse porta. “Ipsum euismod fermentum facilisis quisque eu ut 
> elementum diam.”
> 
> Annotation 2:
> Created at: 2024-10-30 08:02
> Author: Alice Underhill
> Type: Reply
> Comment: Lorem ipsum odor amet, consectetuer adipiscing elit. “Interdum 
> dictumst maecenas lacinia parturient per dignissim etiam quis.”
> 
> Annotation 3:
> Created at: 2024-10-31 19:15
> Author: Andy Absence
> Type: Annotation
> Comment: Lorem ipsum odor amet, consectetuer adipiscing elit. Interdum 
> dictumst maecenas lacinia parturient per dignissim etiam quis. Asapien 
> hendrerit curae; eu malesuada imperdiet et. Lectus taciti curabitur auctor 
> sodales placerat. Mus consequat amet ornare ridiculus mi et ipsum. Nullam est 
> urna interdum nunc ultricies efficitur tellus.
> 
> Annotation 4:
> Created at: 2024-10-31 19:15
> Author: Andy Absence
> Type: Page note
> Comment: Lorem ipsum odor amet, consectetuer adipiscing elit. Interdum 
> dictumst maecenas lacinia parturient per dignissim etiam quis. Asapien 
> hendrerit curae; eu malesuada imperdiet et. Lectus taciti curabitur auctor 
> sodales placerat. Mus consequat amet ornare ridiculus mi et ipsum. Nullam est 
> urna interdum nunc ultricies efficitur tellus.
> 
> Annotation 5:
> Created at: 2024-10-31 19:15
> Author: Andy Absence
> Type: Annotation
> Comment: Lorem ipsum odor amet, consectetuer adipiscing elit. Interdum 
> dictumst maecenas lacinia parturient per dignissim etiam quis. Asapien 
> hendrerit curae; eu malesuada imperdiet et. Lectus taciti curabitur auctor 
> sodales placerat. Mus consequat amet ornare ridiculus mi et ipsum. Nullam est 
> urna interdum nunc ultricies efficitur tellus.
> 
> Annotation 6:
> Created at: 2024-11-03 19:15
> Author: Audrey Afterall
> Type: Page note
> Comment: Lorem ipsum odor amet, consectetuer adipiscing elit. Interdum 
> dictumst maecenas lacinia parturient per dignissim etiam quis. Asapien 
> hendrerit curae; eu malesuada imperdiet et. Lectus taciti curabitur auctor 
> sodales placerat. Mus consequat amet ornare ridiculus mi et ipsum. Nullam est 
> urna interdum nunc ultricies efficitur tellus.
> 
> Annotation 7:
> Created at: 2024-11-03 22:51
> Author: Audrey Afterall
> Type: Annotation
> Comment: Lorem ipsum odor amet, consectetuer adipiscing elit. Interdum 
> dictumst maecenas lacinia parturient per dignissim etiam quis. Asapien 
> hendrerit curae; eu malesuada imperdiet et.
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a feature 
> request or believe that the application isn't working correctly, please email 
> "[email protected]" rather than posting here. Follow @bbedit on Mastodon: 
> <https://mastodon.social/@bbedit>
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To view this discussion visit 
> https://groups.google.com/d/msgid/bbedit/2ca662c0-b506-4a1d-adff-71ebf139178an%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/bbedit/2ca662c0-b506-4a1d-adff-71ebf139178an%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or believe that the application isn't working correctly, please email 
"[email protected]" rather than posting here. Follow @bbedit on Mastodon: 
<https://mastodon.social/@bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/bbedit/B6E0CF76-5C3A-4B93-913D-0BE0C30FD07F%40cumuli.com.

Reply via email to