convert ***sort builtins to use inout instead of references
[hiphop-php.git] / hphp / test / slow / ext_collator / getSortKey.php
blob2abe68d410746559d81d2fc0f48a82cbc7d34570
1 <?hh
3 function sort_key_cmp(Collator $c, string $a, string $b) {
4 $ka = $c->getSortKey($a);
5 $kb = $c->getSortKey($b);
6 if ($ka < $kb) {
7 return -1;
8 } else if ($ka === $kb) {
9 return 0;
10 } else {
11 return 1;
16 <<__EntryPoint>>
17 function main_get_sort_key() {
18 $inputs = array(
19 array('1', '2', '10'),
20 array('y', 'k', 'i'),
23 $locales = array(
24 'en_US',
25 'lt_LT',
28 foreach ($inputs as $input) {
29 foreach ($locales as $locale) {
30 $c = new Collator($locale);
31 usort(inout $input, function($a, $b) use ($c) {
32 return sort_key_cmp($c, $a, $b);
33 });
34 var_dump(array($locale => $input));
35 $c->setAttribute(Collator::NUMERIC_COLLATION, Collator::ON);
36 usort(inout $input, function($a, $b) use ($c) {
37 return sort_key_cmp($c, $a, $b);
38 });
39 var_dump(array($locale.' numeric' => $input));