🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #10099

Re: Sorting of Tables

#10099
From: Peter_Kahrel
Date: Sat, 08 Jul 2006 08:47
43 lines
2564 bytes
Hello Martin,

Funny you should ask, I had just started tinkering with that script again. That table sorter leaves the format of the table alone, by the way (shading, lines, insets, etc.), but local formatting (italics, bold, etc.) goes all over the place. It's not so easy to deal with that in tables.

As to accent-insensitive sorting, I've been looking at that recently. Since languages have different types of sort order for accents, you need language-specific sorters. Some languages sort accents at the end of the unaccented letter, others simply ignore accents. In German it's still different, is it not? Isn't it the case that a vowel with an umlaut is sorted as if that vowel is followed by an 'e', so that M�ller is sorted as Mueller? And the ringel-s is sorted as dubble-s, correct?

I've found some algorithms on the web a while ago, but I didn't understand any of them and as they were in Java they weren't much use to me. The method I came up with is an unelegant brute-force thing, but it works well and is pretty quick. What I do is this. Suppose you have an array with names:

Katich
Kammer
K�rstner

Place a de-accented copy of each name in front of each element, separated by a symbol, let's say #. The array then looks like this:

Katich#Katich
Kammer#Kammer
Kaerstner#K�rstner

Now you sort the list, and finally you remove the first part. Something like this:



//create de-accented dummies 
for( var i in myNames ) 
   myNames[i] = deaccentGerman( myNames[i] ) + '#' + myNames[i]; 
//sort 
myNames.sort(); 
//delete dummies 
for( var i in myNames ) 
   myNames[i] = myNames[i].split('#')[1];

function deaccentGerman( s ) 
{ 
s = s.replace( /\u00E4/g, 'ae' );   //a-umlaut > ae 
s = s.replace( /\u00F6/g, 'oe' ); 
s = s.replace( /\u00FC/g, 'ue' ); 
s = s.replace( /\u00DF/g, 'ss' ); 
return s 
}



Peter
Technical Details
Message-ID: <3bc0c733.1@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!193.190.198.17.MISMATCH!syros.belnet.be!news.belnet.be!news.stben.net!webcrossing
References: <3bc0c733.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,1ad1ec79bcf46a6
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII
From: Peter_Kahrel@adobeforums.com
Newsgroups: adobe.scripting.indesign
Subject: Re: Sorting of Tables
Message-ID: <3bc0c733.1@webcrossing.la2eafNXanI>
Date: Sat, 8 Jul 2006 01:47:05 -0700
References: <3bc0c733.-1@webcrossing.la2eafNXanI>
Lines: 55
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!193.190.198.17.MISMATCH!syros.belnet.be!news.belnet.be!news.stben.net!webcrossing