Last active
August 11, 2017 12:06
-
-
Save lucasmarques73/a56aea19bb4a85d8e27de8a19d69829c to your computer and use it in GitHub Desktop.
Ordenando um array de forma decrescente utilizando for
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nums = [-23,61,18,30,8,-46,69,67,43,617]; | |
for(i = 0; i < nums.length; i++) | |
{ | |
if(nums[i] < nums[i+1]) | |
{ | |
aux = nums[i]; | |
nums[i] = nums[i+1]; | |
nums[i+1] = aux; | |
i = -1; | |
} | |
} | |
console.log(nums) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment