Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 731dfcf

Browse files
committed
Added function to sort array from high to low
1 parent 751b4b3 commit 731dfcf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎JSAlgorithms/sortHighToLow.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function sortHighToLow(array){
2+
let lowestNumber = array[0];
3+
for (i = 0; i < array.length; i++) {
4+
for (k = 0; k <array.length; k++) {
5+
if (array[i] > array[k]) {
6+
let oldNum = array[i];
7+
array[i] = array[k];
8+
array[k] = oldNum;
9+
}
10+
}
11+
}
12+
13+
return array;
14+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /