public function testSortUStrings() { $array = CArray::fromElements("c", "B", "d", "E", "D", "C", "a", "e", "b", "A"); CArray::sortUStrings($array, CUString::COLLATION_DEFAULT); $this->assertTrue(CArray::equals($array, CArray::fromElements("a", "A", "b", "B", "c", "C", "d", "D", "e", "E"))); $array = CArray::fromElements("č", "B", "d", "E", "D", "C", "á", "ê", "b", "A"); CArray::sortUStrings($array, CUString::COLLATION_IGNORE_ACCENTS); $this->assertTrue(CArray::equals($array, CArray::fromElements("á", "A", "b", "B", "č", "C", "d", "D", "ê", "E"))); $array = CArray::fromElements(" c", ",B", ".d", ":E", ";D", "!C", "?a", "\"e", "(b", "[A"); CArray::sortUStrings($array, CUString::COLLATION_IGNORE_NONWORD); $this->assertTrue(CArray::equals($array, CArray::fromElements("?a", "[A", "(b", ",B", " c", "!C", ".d", ";D", "\"e", ":E"))); $array = CArray::fromElements("c", "B", "d", "E", "D", "C", "a", "e", "b", "A"); CArray::sortUStrings($array, CUString::COLLATION_UPPERCASE_FIRST); $this->assertTrue(CArray::equals($array, CArray::fromElements("A", "a", "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. * * For an array that only contains strings, this method is usually preferred over more omnivorous `sort` method. * * **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 * @link #method_sort sort */ public function sortUStrings($collationFlags = CUStringObject::COLLATION_DEFAULT, CULocale $inLocale = null) { CArray::sortUStrings($this->m_splArray, $collationFlags, $inLocale); }