1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16declare function print(arg:any, arg1?:any):string;
17
18let index = 0;
19function randomId()
20{
21    let str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
22    let res = '';
23    for (let i = 0; i < 13; i++) {
24        let n = index + i;
25        res += str[n % str.length];
26    }
27    index++;
28    return res;
29}
30
31let testCount = 0;
32function localeCompareTest()
33{
34    const count = 100;
35    let sortNumber = []
36    for (let i = 0; i < count; i++) {
37        sortNumber.push(randomId());
38    }
39    if (testCount++ == 1) {
40        sortNumber.sort((a, b) => {
41            return a.localeCompare(b)
42        });
43    } else if (testCount++ == 2) {
44        sortNumber.sort((a, b) => {
45            return a.localeCompare(b, undefined)
46        });
47    } else {
48        sortNumber.sort((a, b) => {
49            return a.localeCompare(b, undefined, undefined)
50        });
51    }
52
53    for (let i = 1; i < count; i += 20) {
54        print(sortNumber[i])
55    }
56}
57
58localeCompareTest();
59localeCompareTest();
60localeCompareTest();
61localeCompareTest();
62