|
<html> |
|
|
<head> |
|
|
<title>JavaScript sort which honors static locale settings</title> |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"> |
|
|
</head> |
|
|
<body bgcolor="white"> |
|
|
|
|
|
<p> |
|
|
This is a demo of JavaScript sort which honors static locale LC_COLLATE |
|
|
settings, embedded in one JavaScript variable which can be created from |
|
|
local system using attached perl script. |
|
|
</p><p> |
|
|
Script by Dobrica Pavlinu¹iæ, <dpavlin@rot13.org> 2004-10-24 |
|
|
</p> |
|
|
|
|
|
<tt> |
|
|
|
|
|
<script type="text/javascript"> |
|
1 |
|
|
2 |
// locale in which to sort (basically a alphabet in correct dictionary sort order) |
// locale in which to sort (basically a alphabet in correct dictionary sort order) |
3 |
var _lc_locale = '_0123456789aAáÁãÃâÂäı¡bBcCçÇèÈæÆdDïÏðÐeEéÉìÌëËêÊfFgGhHiIíÍîÎjJkKlLåŵ¥³£mMnNñÑòÒoOóÓôÔöÖõÕpPqQrRàÀøØsS¶¦ºªß¹©tT»«þÞuUúÚùÙüÜûÛvVwWxXyYýÝzZ¼¬¿¯¾®'; |
var _lc_locale = '_0123456789aAáÁãÃâÂäı¡bBcCçÇèÈæÆdDïÏðÐeEéÉìÌëËêÊfFgGhHiIíÍîÎjJkKlLåŵ¥³£mMnNñÑòÒoOóÓôÔöÖõÕpPqQrRàÀøØsS¶¦ºªß¹©tT»«þÞuUúÚùÙüÜûÛvVwWxXyYýÝzZ¼¬¿¯¾®'; |
65 |
} |
} |
66 |
} |
} |
67 |
|
|
|
// test string array of Croatian words |
|
|
var test = [ |
|
|
'abrakadabra', |
|
|
'èevap', |
|
|
'ðak', |
|
|
'd¾amija', |
|
|
'æuk', |
|
|
'pero', |
|
|
'¾aba', |
|
|
'Ðakovo', |
|
|
'Zagreb' |
|
|
]; |
|
|
|
|
|
// create some output |
|
|
document.write( |
|
|
"<br>original: ",test.join(" * "), |
|
|
"<br>native: ",test.sort().join(" * "), |
|
|
"<br>locale: ",test.sort(_lc_sort).join(" * ") |
|
|
); |
|
|
|
|
|
</script> |
|
|
|
|
|
</tt> |
|
|
|
|
|
<br> |
|
|
<p>Sorting finished.</p> |
|
|
|
|
|
</body> |
|
|
</html> |
|