public function testSortUStringsNat() { $array = CArray::fromElements("c", "B", "d", "E", "D", "C", "a", "e", "b", "A3", "A20", "A100"); CArray::sortUStringsNat($array, CUString::COLLATION_DEFAULT); $this->assertTrue(CArray::equals($array, CArray::fromElements("a", "A3", "A20", "A100", "b", "B", "c", "C", "d", "D", "e", "E"))); $array = CArray::fromElements("č", "B", "d", "E", "D", "C", "á", "ê", "b", "A3", "A20", "A100"); CArray::sortUStringsNat($array, CUString::COLLATION_IGNORE_ACCENTS); $this->assertTrue(CArray::equals($array, CArray::fromElements("á", "A3", "A20", "A100", "b", "B", "č", "C", "d", "D", "ê", "E"))); $array = CArray::fromElements(" c", ",B", ".d", ":E", ";D", "!C", "?a", "\"e", "(b", "[A3", "[A20", "[A100"); CArray::sortUStringsNat($array, CUString::COLLATION_IGNORE_NONWORD); $this->assertTrue(CArray::equals($array, CArray::fromElements("?a", "[A3", "[A20", "[A100", "(b", ",B", " c", "!C", ".d", ";D", "\"e", ":E"))); $array = CArray::fromElements("c", "B", "d", "E", "D", "C", "a", "e", "b", "A3", "A20", "A100"); CArray::sortUStringsNat($array, CUString::COLLATION_UPPERCASE_FIRST); $this->assertTrue(CArray::equals($array, CArray::fromElements("a", "A3", "A20", "A100", "B", "b", "C", "c", "D", "d", "E", "e"))); }
/** * Sorts the elements in an array of Unicode or ASCII strings, in the ascending order, case-sensitively, using * natural order comparison. * * To illustrate natural order with an example, an array with strings "a100", "a20", "a3" would be sorted into the * same array with `sortUStrings` method, but as "a3", "a20", "a100" with this method, which is the order a human * being would choose. * * **NOTE.** This method puts lowercase in front of uppercase on per-character basis. * * @param bitfield $collationFlags **OPTIONAL. Default is** `CUStringObject::COLLATION_DEFAULT`. The Unicode * collation option(s) to be used for string comparison. See the [CUStringObject](CUStringObject.html) class for * information on collation options. * @param CULocale $inLocale **OPTIONAL. Default is** *the application's default locale*. The locale in which * strings are to be compared with each other. * * @return void * * @link CUStringObject.html CUStringObject */ public function sortUStringsNat($collationFlags = CUStringObject::COLLATION_DEFAULT, CULocale $inLocale = null) { CArray::sortUStringsNat($this->m_splArray, $collationFlags, $inLocale); }