配列をソートする処理を追加しました #1
1 changed files with 12 additions and 0 deletions
12
sort.js
Normal file
12
sort.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
var sortNumber = function (number) {
|
||||||
|
number.sort(function (a, b) {
|
||||||
|
if (a === b) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return a < b ? -1 : 1;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var number = [19, 3, 81, 1, 24, 21];
|
||||||
|
sortNumber(number);
|
||||||
|
console.log(number);
|
Loading…
Reference in a new issue