0 purchases
sortero
Sortero #
Hecho en 🇵🇷 por Radamés J. Valentín Reyes
Import #
import 'package:sortero/sortero.dart';
copied to clipboard
Extensions: #
- Bubble sort: #
extension #
.bubbleSort()
Parameters #
compare: a function that takes as argument one item of a list and returns a number
reverseOrder: boolean value that determines the order in which stuff is sorted
Example #
Bubble sort #
List<num> algo = [4,6,3,7,8,9];
algo.bubbleSort(
compare: (a){
return a;
},
);
print(algo);
copied to clipboard
Bubble sort reverseOrder parameter #
List<num> algo = [4,6,3,7,8,9];
algo.bubbleSort(
compare: (a){
return a;
},
reverseOrder: true,
);
print(algo);
});
copied to clipboard
Bubble sort async #
List<num> algo = [4,6,3,7,8,9];
await algo.bubbleSortAsync(
compare: (a)async{
return a;
},
reverseOrder: true,
);
print(algo);
copied to clipboard
Pseudo alphabetic sorting #
Use the new getWordValue function to get a numeric value that can be used to kind of sort items alphabetically.
List<String> words = ["Perro", "Gato", "Camión", "Alfombra"];
print(words);
words.bubbleSort(
compare: (word){
return getWordValue(word);
},
);
print("Sorted words: $words");
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.