```{index} single: set_compare (Peta::LMDB::DB) ``` ```{index} single: Peta::LMDB::DB::set_compare ``` # set_compare Order the database's keys by a sort sub of your own. ## Synopsis ```perl $db->set_compare(sub { lc $a cmp lc $b }); ``` ## What you get back Nothing. From then on every transaction uses the sub to place and find keys in this database. ## Edge cases - The sub sees the two keys in `$a` and `$b` of its own package, as a `sort` block does, and returns less than, equal to or greater than zero. - The database does not remember the sub: set the same one every time the environment is opened, before the first read or write. Data stored under one order and read under another is not found. - A sub that dies makes the operation that called it croak with the sub's error, after LMDB has finished it. - A plain value instead of a code reference croaks `Peta::LMDB: set_compare needs a code reference`. ## See also - `set_dupsort` - the order of a key's values - `cmp` (a `Peta::LMDB::Txn` method) - compares two keys this way