Created
May 15, 2019 13:27
-
-
Save airtonGit/52f3982f64bbcc46d00dfcee9be4d818 to your computer and use it in GitHub Desktop.
Javascript Sort Descrescente
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
//Array de exemplo desordenado | |
let listValuesArray = [2010,2009,2015,2011,2019] | |
//Array chama metodo sort com função para ordenar | |
listValuesArray.sort( (a, b) => { | |
if (a > b){ | |
return -1 | |
}else if(a < b){ | |
return 1 | |
}else{ | |
return 0 | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment