473,805 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

true alphabetic sort...

At the moment I'm using a quicksort algorithm to sort a list of
countries in alphabetic order. This worked wonderfully until someone
came up with the Åland Islands... and this is at the end of the list.

I'm not sure it's supposed to be.

Now I could just alter my comparison so it ignores the top bit, but this
would then put it at the top of the list, even before Albania...
Alternatively, should I put Å after A?

In short, is there a preferred way of ordering these?

Thanks,

Ian
Jul 23 '05 #1
13 4886
Ian Richardson <za*****@chaos. org.uk> skrev :
At the moment I'm using a quicksort algorithm to sort a list of
countries in alphabetic order. This worked wonderfully until someone
came up with the Åland Islands... and this is at the end of the list.


Yes, and it's correct.

In swedish, danish and norwegian is "Å" the last letter in the
alphabet.
--
Knud
Jul 23 '05 #2
Knud Gert Ellentoft wrote on 24 apr 2004 in comp.lang.javas cript:
In swedish, danish and norwegian is "Å" the last letter in the
alphabet.


Just curious:

This will write "å" overhere:

document.write( 'Å'.toLowercase )

Does this work for all European alphabets?

=============== ==============

When should I use:

document.write( 'Å'.toLocaleLow erCase())

?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #3
"Evertjan." <ex************ **@interxnl.net > writes:
Just curious:

This will write "å" overhere:

document.write( 'Å'.toLowercase )

Does this work for all European alphabets?
It works for any Unicode letter, using the Unicode character database
for the translation.
=============== ==============

When should I use:

document.write( 'Å'.toLocaleLow erCase())


Never, for the letter "Å".
In ECMA 262, secion 15.5.4.17, the reason given for using
toLocaleLowerCa se, is for languages where the language rules conflict
with the regular Unicode mapping. Tukish is given as an example.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #4
Ivo
"Knud Gert Ellentoft" wrote
Ian Richardson skrev :
At the moment I'm using a quicksort algorithm to sort a list of
countries in alphabetic order. This worked wonderfully until someone
came up with the Åland Islands... and this is at the end of the list.


Yes, and it's correct.
In swedish, danish and norwegian is "Å" the last letter in the
alphabet.


This is interesting. It may be that the Å follows Z in those languages, but
this is new for me and probably the rest of the world. In a long
alphabetical list, I and the OP would look for Å after A, and so I think in
a web-environment it probably should be put there. Where do the French put
the character ç in the French alphabet? Where do the Germans put the ß? I
would look for it after the B.

As for a javascript solution, the easiest would probably be replacing all
occurances of ÀÁÂÃÄÅ and perhaps Æ with an A prior to sorting the list. This
would result in a mix of accented and normal A's which is not perfect. Åland
must come after Aruba but before Bermuda. We must write our own comparison.
It involves

var abc = 'AÀÁÂÃÄÅBßCÇDÐE ÈÉÊËFGHIÌÍÎÏJ' +
'KLMNÑOÒÓÔÕÖØPQ RSSTÙÚÛÜVWXYÝYZ ';

and abc.toLowerCase () and testing for indexOf but I 'm quite not sure how.
The following covers first letters only:

function compare(a, b) {
if (abc.indexOf(a. charAt(0)) < abc.indexOf(b.c harAt(0)))
{
return -1;
}
if (abc.indexOf(a. charAt(0)) > abc.indexOf(b.c harAt(0)))
{
return 1;
}
return 0;
}
var islands=['Curaçao','Bona ire','Åland','A ruba'];
alert(islands.s ort(compare));

HTH
Ìvð
Jul 23 '05 #5
"Ivo" <no@thank.you > skrev :
This is interesting. It may be that the Å follows Z in those languages, but
this is new for me and probably the rest of the world. In a long
alphabetical list, I and the OP would look for Å after A, and so I think in
a web-environment it probably should be put there. Where do the French put
the character ç in the French alphabet? Where do the Germans put the ß? I
would look for it after the B.


I know only the scandinavian languages and a scandinavian would
look for "Å" (and æ.ø.ä and ö) at the the end of the alfabet, so
therefor I would let it be as the last letter.
--
Knud
Jul 23 '05 #6
"Ivo" <no@thank.you > writes:
This is interesting. It may be that the Å follows Z in those languages,
That would be all languages that actually have "Å" as a letter.
but this is new for me and probably the rest of the world.
Hard to say. Microsoft seems to know it. When they alphabetize Danish
words, the double-A, the original form which was turned into the new
letter "Å", comes last (with predictable incorrect results for the
foreign word Aardwark).
In a long alphabetical list, I and the OP would look for Å after A,
and so I think in a web-environment it probably should be put
there.
That entirely depends on the language. If you are sorting words from
different languages, I can see the problem, but would probably prefer
to have it last anyway. It is a letter in its own, not just a letter
with a accent.
Where do the French put the character ç in the French alphabet?
It's a c-cedilla, that is, a "c" with an accent. It is not a separate
letter.
Where do the Germans put the ß? I would look for it after the B.
That would be a weird place to look for a sharp S. It is *not* a beta
(it is an s-z-ligature).
As for a javascript solution, the easiest would probably be replacing all
occurances of ÀÁÂÃÄÅ and perhaps Æ with an A prior to sorting the list.
That's one choice. Since you cannot fix one language to work with, I
don't think there is an official way to alphabetize.
I would probably expand Æ (the a-e-ligature) to AE.
This would result in a mix of accented and normal A's which is not
perfect.


Alas, perfect does not exist.
The closest to perfect for my tastes is to alphabetize letters according
to the language they come from, so Aalborg (Danish city using old spelling)
would be after Zaire, but Aardwark would be under "A".

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #7
Lasse Reichstein Nielsen wrote on 25 apr 2004 in comp.lang.javas cript:
In ECMA 262, secion 15.5.4.17, the reason given for using
toLocaleLowerCa se, is for languages where the language rules conflict
with the regular Unicode mapping. Tukish is given as an example.


Not in
<http://developer.netsc ape.com/docs/javascript/e262-pdf.pdf>
from 1997, which stops at 15.5.4.12

There should be a 3rd edition, but I cannot find it on the web.

Do you have an URL?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #8
"Evertjan." <ex************ **@interxnl.net > writes:
Lasse Reichstein Nielsen wrote on 25 apr 2004 in comp.lang.javas cript:
In ECMA 262, secion 15.5.4.17, the reason given for using
toLocaleLowerCa se, is for languages where the language rules conflict
with the regular Unicode mapping. Tukish is given as an example.
Not in
<http://developer.netsc ape.com/docs/javascript/e262-pdf.pdf>
from 1997, which stops at 15.5.4.12

There should be a 3rd edition, but I cannot find it on the web.

Do you have an URL?


I use this one:
<URL:http://www.mozilla.org/js/language/E262-3.pdf>
It seems to be more recent, and better formatted, than the official
version from ECMA itself. I fail to imaginie an explanation for that :)
<URL:http://www.ecma-international.o rg/publications/files/ecma-st/Ecma-262.pdf>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #9
Lasse Reichstein Nielsen wrote on 25 apr 2004 in comp.lang.javas cript:
I use this one:
<URL:http://www.mozilla.org/js/language/E262-3.pdf>


tnx,

Interesting reading.
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
4273
by: Scott Chapman | last post by:
There seems to be an inconsistency here: Python 2.3.2 (#1, Oct 3 2003, 19:04:58) on linux2 >>> 1 == True True >>> 3 == True False >>> if 1: print "true" ....
11
2459
by: Arpan | last post by:
<% If(False) Then Response.Write("False") Else Response.Write("True") End If %> In the above code, the Else condition will be executed. Why?
2
1686
by: Bit byte | last post by:
I just came accross this : "Note that the STL sort algorithm does NOT work for lists; that's why a sort member function is supplied." Is this true? Has this been fixed in newer versions of the STL?
6
3444
by: py_genetic | last post by:
Hi, I'm looking to generate x alphabetic strings in a list size x. This is exactly the same output that the unix command "split" generates as default file name output when splitting large files. Example: produce x original, but not random strings from english alphabet, all lowercase. The length of each string and possible combinations is
3
3010
by: PulkitZery | last post by:
Hi all, I need some help in my project (VB.NET) here is what I need: I need to convert Alphabetic number (a. b. c. d. …..) into the integers (for example a=1, b=2, c=3 and so on). Can anyone give me a function or point me to an article that explains how to convert these alphabetic number into the integers. Thanks very much in advance. Jerry.
0
1084
by: Martin H. | last post by:
Hi, I've got this problem with an enumeration of a property of a UserControl. The following code shows the problem: Public Enum TestEnum As Integer Arthur = 0 Zachary = -1 End Enum
7
1563
by: emre esirik(hacettepe computer science and enginee | last post by:
I used a structer in this program. typedef struct _guitar { int serial; :serial of item at the guitar store int price; :price of item at the guitar store char builder; :builder of item at the guitar store char type; :type of item at the guitar store char model; :model of item at the guitar store }guitar;
8
5497
crystal2005
by: crystal2005 | last post by:
Hi guys, Just like the title, i'm looking for the example of C program that translates an alphabetic phone number into numeric. The idea as the following output Enter phone number: 1800-TEST-100 result: 1800-8378-100 so basically 2=ABC, 3=DEF, 4=GHI, . . . , 9 = WXYZ
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10361
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10103
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9179
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7644
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4316
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3839
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.