Returns the sorted array,
Desc defaults to false,
Desc is true, sorting an array in descending order way,
Desc to false, the array in ascending order,
Desc set the default values? The initial default value is undefined?
CodePudding user response:
Var arr=[1, 3, 6, 2],Desc=[5, 6, 8, 7].
Arr. Sort ();
Document. The write (arr);
Document. Write (" & lt; Br>" )
Document. The write (desc);
The function sort (desc) {
Let aDef=desc? Desc: 'false'
The console. The log (aDef);
}
The function sd (a, b) {
If (a> B) {
return true;
} else {
return false;
}
}
Arr. Sort (sd);
The console. The log (desc)
CodePudding user response: