• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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
16class DeepProxy {
17    constructor(obj, handler) {
18        return new Proxy(obj, handler);
19    }
20}
21class ClassB {
22    constructor(n) {
23        this.n = 0;
24        this.n = n;
25    }
26}
27
28let nextFreeId = 0;
29class ClassA {
30    constructor(a, b) {
31        this.a = a;
32        this.b = new ClassB(b);
33        this.id = nextFreeId++;
34    }
35}
36
37// Testing the proxy situation.
38let data1 = [new ClassA(1, 10), new ClassA(3, 30), new ClassA(4, 40), new ClassA(2, 20), new ClassA(11, 250)];
39let objHandler1 = new DeepProxy(data1, {});
40print(JSON.stringify(objHandler1));
41objHandler1.sort((a, b) => {
42    return a.b.n - b.b.n;
43})
44print(JSON.stringify(objHandler1));
45
46// Testing cases with both proxy and hole.
47let data2 = [new ClassA(1, 10), , new ClassA(3, 30), , new ClassA(4, 40), new ClassA(2, 20), new ClassA(11, 250)];
48let objHandler2 = new DeepProxy(data2, {
49    deleteProperty(target, prop) {
50        print(`delete ${prop.toString()}`);
51        return Reflect.deleteProperty(target, prop);
52    }
53});
54objHandler2.sort((a, b) => {
55    return a.b.n - b.b.n;
56})
57print(JSON.stringify(objHandler2));
58
59/*
60 * Test Case Description:
61 * 1. This use case is used to verify the logical processing order of the binary insertion sorting algorithm.
62 * 2. If there are any changes to the use case, please confirm if the use case needs to be modified.
63 */
64let arr1 = [1, 3, 2];
65arr1.sort((a, b) => {
66    return a - b;
67});
68print(JSON.stringify(arr1));
69
70/*
71 * Test Case Description:
72 * 1. This use case is used to verify the logical processing order of the quick sorting algorithm.
73 * 2. If there are any changes to the use case, please confirm if the use case needs to be modified.
74 */
75for (let i = 0; i < 100; i++) {
76    arr1[i] = i;
77}
78arr1[0] = 99;
79arr1[99] = 0;
80arr1[49] = 50;
81arr1[50] = 49;
82arr1.sort((a, b) => {
83    return a - b;
84})
85print(JSON.stringify(arr1));
86
87// Modification of objects during the comparison process.
88let arr2 = [1, 3, 2];
89arr2.sort((a, b) => {
90    if (a == 1 || b == 1) {
91        arr2[0] == 2;
92    }
93    return a - b;
94});
95print(JSON.stringify(arr2));
96
97let arr3 = [1, 3, 2];
98arr3.sort((a, b) => {
99    if (a == 1 || b == 1) {
100        arr3[4] == 2;
101    }
102    return a - b;
103});
104print(JSON.stringify(arr3));
105
106// Testing the situation where this is an Object
107let obj1 = {0: 1, 1: 3, a: 6, 2: 2, length: 3};
108Array.prototype.sort.call(obj1, (a, b) => {
109    return a - b;
110});
111print(JSON.stringify(obj1));
112
113let obj2 = {0: 1, 1: 3, a: 6, 2: 2, length: 3};
114Array.prototype.sort.call(obj2, (a, b) => {
115    if (a == 1 || b == 1) {
116        obj2.a = 60;
117    }
118    return a - b;
119});
120print(obj2.a == 60);
121print(JSON.stringify(obj2));
122
123let obj3 = {0: 1, 1: 3, a: 6, 2: 2, length: 2};
124Array.prototype.sort.call(obj3, (a, b) => {
125    return a - b;
126});
127print(obj3[1] == 3)
128print(JSON.stringify(obj3));
129
130let obj4 = {0: 1, 1: 3, a: 6, 3: 2, length: 4};
131Array.prototype.sort.call(obj4, (a, b) => {
132    return a - b;
133});
134print(obj4[2] == 3)
135print(JSON.stringify(obj4));
136
137// Test if this is a Map type;
138let map1 = new Map();
139map1.set(0, 1);
140map1.set(1, 3);
141map1.set(2, 2);
142map1.set("a", 6);
143map1.set("length", 3);
144Array.prototype.sort.call(map1, (a, b) => {
145    return a - b;
146});
147print(JSON.stringify(map1));
148
149let map2 = new Map();
150map2.set(0, 1);
151map2.set(1, 3);
152map2.set(2, 2);
153map2.set("a", 6);
154map2.set("length", 3);
155Array.prototype.sort.call(map2, (a, b) => {
156    if (a == 1 || b == 1) {
157        map2.set("a", 60);
158    }
159    return a - b;
160});
161print(JSON.stringify(map2));
162
163// Test prototype
164let child1 = [1, 3, 2];
165let proto1 = [4, 7, 5];
166child1.__proto__ = proto1;
167child1.sort((a, b) => {
168    return a - b;
169});
170print(JSON.stringify(child1));
171
172let child2 = [1, , 2];
173child2.__proto__ = proto1;
174child2.sort((a, b) => {
175    return a - b;
176});
177print(child2.hasOwnProperty('1'));
178print(JSON.stringify(child2));
179
180let child3 = [1, 3, 2];
181let proto2 = [4, , 5];
182child3.__proto__ = proto2;
183child3.sort((a, b) => {
184    return a - b;
185});
186print(JSON.stringify(child3));
187
188let child4 = [1, , 2];
189child4.__proto__ = proto2;
190child4.sort((a, b) => {
191    return a - b;
192});
193print(child4.hasOwnProperty('2'));
194print(JSON.stringify(child4));
195
196var test1 = [-321, 65, 0, -3215, 653, 650, -3210, -2147483648, 2147483647];
197print(test1.sort());
198
199
200var arr4 = new Array(5);
201arr4[0] = 93;
202arr4[1] = 930;
203arr4[2] = -45;
204arr4[3] = 44;
205arr4[4] = 0;
206print(arr4.sort(function(a, b){
207    a--;
208    b--;
209    return b-a;
210}));
211
212var arr5 = [3, 1, 4];
213arr5.sort((a, b) => {
214    if (a == 1 || b == 1) {
215        arr5[0] = 6;
216    }
217    return a - b;
218});
219print(arr5);
220
221Object.defineProperty(Array.prototype, "tt", {
222    value:37,
223    writable:false,
224});
225
226var arr6 = new Array(5);
227arr6[0] = 93;
228arr6[2] = -45;
229arr6[3] = "djs";
230arr6[4] = 0;
231print(arr6.sort());
232
233var arr7 = [1];
234print(arr7.sort());
235
236var res1 = Array.prototype.sort.call("m", Uint8Array);
237print(res1);
238
239try {
240    Array.prototype.sort.call("mm", Uint8Array);
241} catch (e) {
242    print(e.name);
243}
244
245const o1 = {
246    ..."654"
247};
248const arr8 = [1, 2, 3];
249const o2 = {
250    __proto__: arr8,
251    ...o1
252};
253o2.sort();
254print(o2[0]);
255print(o2[1]);
256print(o2[2]);
257
258const bigint64_array = new BigInt64Array();
259const proxy = new Proxy([1, 2, 3], bigint64_array);
260try {
261    proxy.sort();
262} catch (e) {
263    print(e.name);
264}
265
266try {
267    const vSort = new Float64Array(Float64Array);
268    vSort.__proto__.sort();
269} catch (e) {
270    print(e.message);
271}
272
273const v4 = [1, 255];
274class C5 extends Int16Array{
275    toString(a7, a8, a9, a10) {
276        super.includes();
277    }
278}
279try {
280    const v12 = new C5();
281    v4.sort(C5.prototype.toString);
282} catch (e) {
283    print(e.message);
284}
285const items = [
286    { name: "Edward", value: 21 },
287    { name: "Sharpe", value: 37 },
288    { name: "And", value: 45 },
289    { name: "The", value: -12 },
290    { name: "Magnetic", value: 13 },
291    { name: "Zeros", value: 37 },
292  ];
293
294items.sort((a, b) => a.value - b.value);
295print(JSON.stringify(items));
296
297items.sort((a, b) => {
298    const nameA = a.name.toUpperCase();
299    const nameB = b.name.toUpperCase();
300    if (nameA < nameB) {
301      return -1;
302    }
303    if (nameA > nameB) {
304      return 1;
305    }
306    return 0;
307  });
308
309print(JSON.stringify(items));
310
311const numbers = [3, 1, 4, 1, 5];
312const sorted = numbers.sort((a, b) => a - b);
313sorted[0] = 10;
314print(numbers[0]); // 10
315
316const students = [
317    { name: "Alex", grade: 15 },
318    { name: "Devlin", grade: 15 },
319    { name: "Eagle", grade: 13 },
320    { name: "Sam", grade: 14 },
321];
322// stable
323students.sort((firstItem, secondItem) => firstItem.grade - secondItem.grade);
324print(JSON.stringify(students));
325const v2 =[];
326class C3{};
327v2.__proto__ = C3;
328let arr = new Array(518);
329for(let i=0;i<518;i++){
330    arr[i]=""+i;
331}
332arr[512]="valueOf";
333arr[513]="p0";
334arr[514]="p1";
335arr[515]="p2";
336arr[516]="p3";
337arr[517]="p4";
338arr.sort();
339
340//for cmp return type is double
341let arr34 = [2.63, 1.67];
342print(arr34.sort((a, b)=> a - b));
343print("sort Test Success!");
344
345// String toSorted
346{
347	let array1 = new Array();
348    for (let i = 0; i < 1; i++) array1[i] = `string.${i}`;
349    print(array1.toSorted());
350
351    array1 = new Array();
352    for (let i = 0; i < 2; i++) array1[i] = `string.${i}`;
353    print(array1.toSorted());
354
355    array1 = new Array();
356    for (let i = 0; i < 2; i++) array1[i] = `string.${1 - i}`;
357    print(array1.toSorted());
358
359    array1 = new Array();
360    array1[0] = `a`;
361    array1[1] = `b`;
362    array1[2] = `c`;
363    array1[3] = `d`;
364    array1[4] = `e`;
365    array1[5] = `f`;
366    array1[6] = `g`;
367    print(array1.toSorted());
368
369    array1 = new Array();
370    array1[6] = `a`;
371    array1[5] = `b`;
372    array1[4] = `c`;
373    array1[3] = `d`;
374    array1[2] = `e`;
375    array1[1] = `f`;
376    array1[0] = `g`;
377    print(array1.toSorted());
378}
379
380// Test sort if array has hole
381function HoleSort()
382{
383  let sortNumber= [];
384  for (let i = 0; i < 10; i++) {
385    sortNumber.push(parseInt(i));
386  }
387  sortNumber[100] = parseInt(100);
388  print(sortNumber.length);
389  print(sortNumber);
390
391  sortNumber.sort((a, b) => {
392    return a < b;
393  });
394
395  print(sortNumber.length);
396  print(sortNumber);
397}
398
399HoleSort();
400
401let sortNumber = [0,3,2,,4,5,6];
402sortNumber.sort((a,b) => {
403    sortNumber[10000] = 1;
404    return a-b;
405});
406print(sortNumber.length);
407print(sortNumber);
408
409let sortNumber2 = [0,3,2,,4,5,6];
410sortNumber2.sort((a,b) => {
411    sortNumber2[3] = 1;
412    return a-b;
413});
414print(sortNumber2.length);
415print(sortNumber2);
416
417let sortNumber3 = [0,3,2,,4,5,6];
418sortNumber3.sort((a,b) => {
419    sortNumber3 = 1;    // stlexvar
420    return a-b;
421});
422print(sortNumber3.length);
423print(sortNumber3[0]);
424print(sortNumber3[2]);
425print(sortNumber3[4]);
426print(sortNumber3[6]);
427
428let sortNumber4 = [0,3,2,,4,5,6];
429sortNumber4.sort((a,b) => {
430    sortNumber4.push(1);
431    return a-b;
432});
433print(sortNumber4.length);
434print(sortNumber4[0]);
435print(sortNumber4[2]);
436print(sortNumber4[4]);
437print(sortNumber4[6]);
438
439let sortNumber5 = [-1, 2, 4, 1, 0];
440sortNumber5.sort((x, y) => {
441    Object.defineProperty(sortNumber5, '2', {
442        get() {
443            print("get second element:");
444            return this.value;
445        },
446        set(newValue) {
447            print("set second element:", newValue);
448            this.value = newValue;
449        }
450    });
451    return x - y;
452})
453print(sortNumber5.length);
454print(sortNumber5.value);
455print(sortNumber5);
456
457let sortNumber6 = [-1, 2, 4, 1, 0];
458sortNumber6.sort((x, y) => {
459    Object.defineProperty(sortNumber6, '100', {
460        get() {
461            print("get 10000th element:");
462            return this.value;
463        },
464        set(newValue) {
465            print("set 10000th element:", newValue);
466            this.value = newValue;
467        },
468        configurable: true  // 允许重新定义
469    });
470    return x - y;
471})
472print(sortNumber6.length);
473print(sortNumber6.value);
474print(sortNumber6);
475
476let sortNumber7 = [0,3,2,,4,5,6];
477sortNumber7.sort((a,b) => {
478    sortNumber7.pop();
479    return a-b;
480});
481print(sortNumber7.length);
482print(sortNumber7[0]);
483print(sortNumber7[2]);
484print(sortNumber7[4]);
485print(sortNumber7[6]);
486// double sort
487{
488    let array1 = new Array();
489    array1[0] = NaN;
490    array1[1] = 0.0;
491    array1[2] = 1;
492    array1[3] = -0.1;
493    array1[4] = Infinity;
494    array1[5] = -Infinity;
495    array1[10] = NaN;
496    array1[11] = 0.0;
497    array1[12] = 1;
498    array1[13] = -0.1;
499    array1[14] = Infinity;
500    array1[15] = -Infinity;
501    print(array1.toSorted());
502
503    array1 = [5562684646268003, 0.005431, 0.00000019045, -79.39773355813419,
504        1e21, 340000000000000000, 12.01234567890123456789, 0.000001234567890123456789, Infinity,
505        -Infinity, 1.7976931348623157e+308, -1.7976931348623157e+308, 2.22507e-308,
506        0.0000001234567890123456789, 3.4e21, 1.2e20, 1.2e0, 1.2e-6, 1.2e-7, NaN, -12.01234567890123456789,
507        -0.000001234567890123456789, -0.0000001234567890123456789, -3.4e21, -1.2e20, -1.2e0, -1.2e-6, -1.2e-7,
508        0.0, 0
509    ];
510    print(array1.toSorted());
511}
512
513{
514    // double sort need barrier
515    let arrayInt = new Array(3,2,1,0);
516    print(arrayInt.sort());
517    let arrayHoleInt = new Array(4);
518    arrayHoleInt[1] = 4;
519    arrayHoleInt[3] = 2;
520    arrayHoleInt[4] = 1;
521    print(arrayHoleInt.sort());
522
523    let arrayNumber = new Array(3.1, 2.1, 1.1, 0);
524    print(arrayNumber.sort());
525    let arrayHoleNumber = new Array(4);
526    arrayHoleNumber[1] = 4.1;
527    arrayHoleNumber[3] = 2.1;
528    arrayHoleNumber[4] = 1.1;
529    print(arrayHoleNumber.sort());
530}
531
532{
533    let array1;
534    function arrayToString(arr) {
535        return arr.map(e => {
536            if (e === undefined) {
537                return 'undefined';
538            }
539            return e == null ? "null" : e.toString();
540        });
541    }
542    // object toString
543    function objectToSorted(){
544        let array1 = new Array();
545        array1 = new Array();
546        for (let i = 0; i < 5; i++) array1[i] = { ["obj" + i]: i };
547        return array1.toSorted();
548    }
549    // has hole,undefined,false,true,null
550    function specialValueToSorted() {
551        array1 = new Array();
552        array1[1] = undefined;
553        array1[2] = false;
554        array1[3] = true;
555        array1[4] = null;
556        return array1.toSorted();
557
558    }
559    // Symbol element toSorted
560    function symbolToSorted() {
561        array1 = new Array();
562        for (let i = 0; i < 5; i++){
563            array1[i] = {
564                [Symbol.toPrimitive](hint) {
565                    return 5 - i;
566                },
567            };
568        }
569        return array1.toSorted();
570    }
571    // number element toSorted
572    function numberToSorted() {
573       array1 = new Array();
574        for (let i = 0; i < 5; i++) {
575            array1[i] = 5-i;
576        }
577        return array1.toSorted();
578    }
579    // bigint element toSorted
580    function bigIntToSorted() {
581        array1 = new Array();
582        array1[0] = 5n;
583        array1[1] = 4n;
584        array1[2] = 3n;
585        array1[3] = 2n;
586        array1[4] = 1n;
587        return array1.toSorted();
588    }
589    // object rewrite toString element toSorted
590    function objectRewriteToSorted() {
591        class Cat{
592        }
593        Cat.prototype.toString = function () {
594            return -1;
595        }
596        array1 = new Array();
597        array1[0] = 5;
598        array1[1] = 4;
599        array1[2] = 3;
600        array1[3] = 2;
601        array1[4] = new Cat();
602        return array1.toSorted();
603    }
604    // symbol throw error element toSorted
605    function symbolThrowToSorted() {
606        array1 = new Array();
607        array1[0] = 5;
608        array1[1] = 4;
609        array1[2] = 3;
610        array1[3] = 2;
611        array1[4] = {
612                [Symbol.toPrimitive](hint) {
613                    throw new Error("Symbol.toPrimitive");
614                }
615            };
616        return array1.toSorted();
617    }
618
619    // symbol return object element toSorted
620    function symbolNotStringToSorted() {
621        array1 = new Array();
622        array1[0] = 5;
623        array1[1] = 4;
624        array1[2] = 3;
625        array1[3] = 2;
626        array1[4] = {
627                [Symbol.toPrimitive](hint) {
628                    return {};
629                }
630            };
631        return array1.toSorted();
632    }
633
634    // object toString throw error toSorted
635    function objectToStringThrowErrorToSorted() {
636        class Cat{
637        }
638        Cat.prototype.toString = function () {
639            throw new Error("toString");
640        }
641        array1 = new Array();
642        array1[0] = 5;
643        array1[1] = 4;
644        array1[2] = 3;
645        array1[3] = 2;
646        array1[4] = new Cat();
647        return array1.toSorted();
648    }
649
650    // object valueOf element toSorted
651    function objectValueOfToSorted() {
652        class Cat{
653        }
654        Cat.prototype.toString = function () {
655            return {};
656        }
657        Cat.prototype.valueOf = function () {
658            return -1;
659        }
660        array1 = new Array();
661        array1[0] = 5;
662        array1[1] = 4;
663        array1[2] = 3;
664        array1[3] = 2;
665        array1[4] = new Cat();
666        return array1.toSorted();
667    }
668
669    // object valueOf throw error toSorted
670    function objectValueOfThrowErrorToSorted() {
671        class Cat{
672        }
673        Cat.prototype.toString = function () {
674            return {};
675        }
676        Cat.prototype.valueOf = function () {
677            throw new Error("valueOf");
678        }
679        array1 = new Array();
680        array1[0] = 5;
681        array1[1] = 4;
682        array1[2] = 3;
683        array1[3] = 2;
684        array1[4] = new Cat();
685        return array1.toSorted();
686    }
687
688    // object valueOf toString return {} toSorted
689    function objectNoStringToSorted() {
690        class Cat{
691        }
692        Cat.prototype.toString = function () {
693            return {};
694        }
695        Cat.prototype.valueOf = function () {
696            return {};
697        }
698        array1 = new Array();
699        array1[0] = 5;
700        array1[1] = 4;
701        array1[2] = 3;
702        array1[3] = 2;
703        array1[4] = new Cat();
704        return array1.toSorted();
705    }
706    // Cannot convert a illegal value to a String; toSorted
707    function CannotConvertIllegalValueToStringToSorted() {
708        array1 = new Array();
709        array1[0] = Symbol("1");
710        array1[1] = Symbol("1");
711        array1[2] = Symbol("1");
712        array1[3] = Symbol("1");
713        array1[4] = Symbol("1");
714        return array1.toSorted();
715    }
716
717    // date hint sort
718    function dateHintSort()
719    {
720        // default datehint string sort;
721        let a = new Date('10 December 2019 14:48');
722        let a1 = new Date('10 December 2019 14:48');
723        let b = new Date('11 December 2019 14:48');
724        let b1 = new Date('11 December 2019 14:48');
725        let c = new Date('12 December 2019 14:48');
726        let c1 = new Date('12 December 2019 14:48');
727        let d = new Date('13 December 2019 14:48');
728        let d1 = new Date('13 December 2019 14:48');
729        let e = new Date('14 December 2019 14:48');
730        let e1 = new Date('14 December 2019 14:48');
731        let dateHint = [a, b, c, d, e];
732        // Fri Dec 13 2019 14:48:00 GMT+0800,Sat Dec 14 2019 14:48:00 GMT+0800,Thu Dec 12 2019 14:48:00 GMT+0800,Tue Dec 10 2019 14:48:00 GMT+0800,Wed Dec 11 2019 14:48:00 GMT+0800
733        print(dateHint.sort());
734        a[Symbol.toPrimitive] = (hint)=>{
735            return a1[Symbol.toPrimitive]('number');
736        };
737        b[Symbol.toPrimitive] = (hint)=>{
738            return b1[Symbol.toPrimitive]('number');
739        };
740        c[Symbol.toPrimitive] = (hint)=>{
741            return c1[Symbol.toPrimitive]('number');
742        };
743        d[Symbol.toPrimitive] = (hint)=>{
744            return d1[Symbol.toPrimitive]('number');
745        };
746        e[Symbol.toPrimitive] = (hint)=>{
747            return e1[Symbol.toPrimitive]('number');
748        };
749        print(dateHint.sort());
750    }
751    // [object Object],[object Object],[object Object],[object Object],[object Object]
752    print(objectToSorted());
753    // false,null,true,undefined,undefined
754    print(arrayToString(specialValueToSorted()));
755    // 1,2,3,4,5
756    print(symbolToSorted());
757    // 1,2,3,4,5
758    print(numberToSorted());
759    // 1,2,3,4,5
760    print(bigIntToSorted());
761    // -1,2,3,4,5
762    print(objectRewriteToSorted());
763    // Symbol.toPrimitive
764    try {
765        symbolThrowToSorted()
766    } catch (e) {
767        print(e.message);
768    }
769    // Cannot convert object to primitive value
770    try {
771        symbolNotStringToSorted();
772    } catch (e) {
773        print(e.message);
774    }
775    // toString
776    try {
777        objectToStringThrowErrorToSorted()
778    } catch (e) {
779        print(e.message);
780    }
781    // -1,2,3,4,5
782    print(objectValueOfToSorted());
783    // valueOf
784    try {
785        objectValueOfThrowErrorToSorted()
786    } catch (e) {
787        print(e.message);
788    }
789    // Cannot convert object to primitive value
790    try {
791        objectNoStringToSorted();
792    } catch (e) {
793        print(e.message);
794    }
795    // Cannot convert a illegal value to a String
796    try {
797        CannotConvertIllegalValueToStringToSorted();
798    } catch (e) {
799        print(e.message);
800    }
801    dateHintSort();
802}
803
804
805{
806    print("---------------test for stable array sort where arr changeto dictionary array during sorting-----------")
807    let arr = new Array(20);
808    let haschang = false;
809    for (let i = 0; i < arr.length; i++) {
810        arr[i] = i;
811    }
812    arr[1] = {
813        toString() {
814            if (!haschang) {
815                arr.length = 102400;
816            }
817            return -999;
818        }
819    }
820    arr.sort();
821    arr.splice(-1, 1);
822    print("---------------test for stable array sort where arr changeto dictionary array during sorting end-------")
823}
824{
825    print("---------------test for stable array sort where elements length change---------------------------------")
826    let arr = new Array(20);
827    let haschang = false;
828    for (let i = 0; i < arr.length; i++) {
829        arr[i] = i;
830    }
831    arr[1] = {
832        toString() {
833            if (!haschang) {
834                arr.splice(-1, 1);
835            }
836            return -999;
837        }
838    }
839    arr.sort();
840    arr.splice(-1, 1)
841    print("---------------test for stable array sort where elements length change end-----------------------------")
842}
843{
844    print("---------------test for string array sort---------------------------------")
845    let arr = new Array("aa","ab","ac","abc","abb","aba","a","b","c",);
846    print(arr.toSorted());
847    print("---------------test for string array sort end-----------------------------")
848}
849