1--TEST--
2collator_get_sort_key() icu >= 53.1 && icu < 54.1
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5<?php if (version_compare(INTL_ICU_VERSION, '53.1') < 0) die('skip for ICU >= 53.1'); ?>
6<?php if (version_compare(INTL_ICU_VERSION, '54.1') >=  0) die('skip for ICU < 54.1'); ?>
7--FILE--
8<?php
9
10/*
11 * Get sort keys using various locales
12 */
13function sort_arrays( $locale, $data )
14{
15    $res_str = '';
16
17    $coll = ut_coll_create( $locale );
18
19	foreach($data as $value) {
20		$res_val = ut_coll_get_sort_key( $coll, $value );
21		$res_str .= "source: ".$value."\n".
22					"key: ".bin2hex($res_val)."\n";
23	}
24
25    return $res_str;
26}
27
28
29function ut_main()
30{
31    $res_str = '';
32
33    // Regular strings keys
34    $test_params = array(
35		'abc', 'abd', 'aaa',
36		'аа', 'а', 'z',
37		'', null , '3',
38        'y'  , 'i'  , 'k'
39    );
40
41    $res_str .= sort_arrays( 'en_US', $test_params );
42
43    // Sort a non-ASCII array using ru_RU locale.
44    $test_params = array(
45		'абг', 'абв', 'жжж', 'эюя'
46    );
47
48    $res_str .= sort_arrays( 'ru_RU', $test_params );
49
50    // Sort an array using Lithuanian locale.
51    $res_str .= sort_arrays( 'lt_LT', $test_params );
52
53    return $res_str . "\n";
54}
55
56include_once( 'ut_common.inc' );
57ut_run();
58?>
59--EXPECT--
60source: abc
61key: 292b2d01070107
62source: abd
63key: 292b2f01070107
64source: aaa
65key: 29292901070107
66source: аа
67key: 5e090901060106
68source: а
69key: 5e0901050105
70source: z
71key: 5b01050105
72source:
73key: 0101
74source:
75key: 0101
76source: 3
77key: 1a01050105
78source: y
79key: 5901050105
80source: i
81key: 3901050105
82source: k
83key: 3d01050105
84source: абг
85key: 2809131701070107
86source: абв
87key: 2809131501070107
88source: жжж
89key: 2833333301070107
90source: эюя
91key: 28cdd1d501070107
92source: абг
93key: 5e09131701070107
94source: абв
95key: 5e09131501070107
96source: жжж
97key: 5e33333301070107
98source: эюя
99key: 5ecdd1d501070107
100