Combine Lists: Append difference to end of

I have a script to generate a list of “Names___ page number.”
What I need to do is compare similar entries and add a comma and page number at the end.
(ie.)
Filename___1
Filename___3
OtherName__4

Becomes:
Filename__1, 3
OtherName__4
etc.

I know a Scripting Addition can handle this but I am having trouble identifying and implementing one of the solutions.

Any ideas?

Thank you,

Steven.

If your delimiter between the item and the page number is always constant (in this case, “___”) then this should work for you:

Jon

Wow! I was only expecting some suggestions. Thank you very much for taking the time to put this together.

Now, for the embarrassing part . . . I only gave the example as a rough idea. I should have just given exactly what I needed. Here is one element from my list –

set x to (“@category:” & "n " & x & " | " & “<\t>” & thisPage) as text

My script collects this information from 8 different Quark documents and compiles them through Word into an index.
@category” is a style sheet
"n " gets converted to “Zapf Dingbats”
x is the name pulled from the documents (based on style sheet)
“|” is just a separator in the text
“<\t>” is a tab
thisPage is the name of the page number the x is on

This whole line is text.
So, I need to determine if
@category:n GERMAN SHORTHAIRED POINTER | < >78”, ¬
@category:n GERMAN SHORTHAIRED POINTER | < >79”, “@category:n GOLDEN RETRIEVER | < >79”,

can be reduced to two lines since German shorthaired pointer has two entries for the same category but the pages will be 78, 79.

I was hoping to translate what you provided before, but I cannot quote make sense out of it.

Again, thank you so much for your post and I apologize for my mistake. Any modification you could suggest to your original post would be most appreciated.

Thank you

Steven.