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 40bc4c1

Browse files
Merge pull request #14 from Ameer67/sort-low-to-high
Added function to sort array from low to high
2 parents 010fec6 + 944d27c commit 40bc4c1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎JSAlgorithms/sortLowToHigh.js

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

0 commit comments

Comments
(0)

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