Skip to content

Instantly share code, notes, and snippets.

@ulisseshen
Last active March 1, 2023 17:55
Show Gist options
  • Save ulisseshen/02b18e386cfa27238a265728b5ddd6bf to your computer and use it in GitHub Desktop.
Save ulisseshen/02b18e386cfa27238a265728b5ddd6bf to your computer and use it in GitHub Desktop.
Um sistema sismples mostrando a ordenação ASC e DESC de uma lista de números em Dart
void main() {
List<int> numeros = [0, 5, 2, 4, 7, 1, 9, 6, 3, 8];
print(numeros);
// [0, 5, 2, 4, 7, 1, 9, 6, 3, 8]
//ASC - ascendente
numeros.sort();
print(numeros);
// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
//DESC - descendente
numeros.sort((a,b)=> -a.compareTo(b));
print(numeros);
// [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment