1 |
<html> |
2 |
<head> |
3 |
<title>JavaScript sort which honors static locale settings</title> |
4 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"> |
5 |
</head> |
6 |
<body bgcolor="white"> |
7 |
|
8 |
<p> |
9 |
This is a demo of JavaScript sort which honors static locale LC_COLLATE |
10 |
settings, embedded in one JavaScript variable which can be created from |
11 |
local system using attached perl script. |
12 |
</p><p> |
13 |
Script by Dobrica Pavlinu¹iæ, <dpavlin@rot13.org> 2004-10-24 |
14 |
</p> |
15 |
|
16 |
<tt> |
17 |
|
18 |
<script type="text/javascript" src="locale.js"> </script> |
19 |
<script type="text/javascript"> |
20 |
|
21 |
// test string array of Croatian words |
22 |
var test = [ |
23 |
'abrakadabra', |
24 |
'èevap', |
25 |
'ðak', |
26 |
'd¾amija', |
27 |
'æuk', |
28 |
'pero', |
29 |
'¾aba', |
30 |
'Ðakovo', |
31 |
'Zagreb' |
32 |
]; |
33 |
|
34 |
// create some output |
35 |
document.write( |
36 |
"<br>original: ",test.join(" * "), |
37 |
"<br>native: ",test.sort().join(" * "), |
38 |
"<br>locale: ",test.sort(_lc_sort).join(" * ") |
39 |
); |
40 |
|
41 |
</script> |
42 |
|
43 |
</tt> |
44 |
|
45 |
<br> |
46 |
<p>Sorting finished.</p> |
47 |
|
48 |
</body> |
49 |
</html> |