# The `Lua-UCA` package This package adds support for the [Unicode collation algorithm](https://unicode.org/reports/tr10/) for Lua 5.3. ## Install The package needs to download Unicode collation data and convert it to a Lua table. It depends on `wget` and `unzip` utitilities. To install the package in the local TEXMF tree, run: make make install ## Usage To sort a table using Czech collation rules: kpse.set_program_name "luatex" local ducet = require "lua-uca.lua-uca-ducet" local collator = require "lua-uca.lua-uca-collator" local languages = require "lua-uca.lua-uca-languages" local collator_obj = collator.new(ducet) -- load Czech rules collator_obj = languages.cs(collator_obj) local t = {"cihla", "chochol", "hudba", "jasan", "čáp"} table.sort(t, function(a,b) return collator_obj:compare_strings(a,b) end) for _, v in ipairs(t) do print(v) end The output: > cihla > čáp > hudba > chochol > jasan More samples of use can be found in the `spec` directory. `tools/indexing-sample.lua` is a simple indexing processor. ## Use with Xindex processor [Xindex](https://www.ctan.org/pkg/xindex) is flexible index processor written in Lua by Herbert Voß. It supports Lua configuration files, which enables use of Lua-UCA for sorting of the index entries, as shown in [this example](https://tex.stackexchange.com/a/524014/2891) for Norwegian text. The `xindex` directory in the [source repository](https://github.com/michal-h21/lua-uca/tree/master/xindex) contains more advanced version of such configuration file together with several examples. Run `make xindex` command to compile them. ## Change sorting rules The simplest way to change the default sorting order is to use the `tailor_string` method of the `collator_obj` object. It updates the collator object using special syntax which is subset of the format used by the [Unicode locale data markup language](https://www.unicode.org/reports/tr35/tr35-collation.html#Orderings). collator_obj:tailor_string "&a