Skip to content

Instantly share code, notes, and snippets.

@lucasmarques73
Last active August 11, 2017 12:06
Show Gist options
  • Save lucasmarques73/a56aea19bb4a85d8e27de8a19d69829c to your computer and use it in GitHub Desktop.
Save lucasmarques73/a56aea19bb4a85d8e27de8a19d69829c to your computer and use it in GitHub Desktop.
Ordenando um array de forma decrescente utilizando for
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