Skip to content

Commit 3b46508

Browse files
ALaurinneMohamad655
authored andcommitted
Add BubbleSort in Dart Language
1 parent 908f075 commit 3b46508

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
void main() {
2+
List<int> array = <int>[10, -4, 7, 3, 1, 0, 2, 6, 99];
3+
BubbleSort(array);
4+
5+
for (int i = 0; i < array.length - 1; i++) print(array[i]);
6+
}
7+
8+
List<int> BubbleSort(List<int> list) {
9+
print("Bubble Sort: ");
10+
for (int i = 0; i < list.length; i++) {
11+
for (int j = 0; j < list.length - 1; j++) {
12+
if (list[j] > list[j + 1]) {
13+
int num = list[j];
14+
list[j] = list[j + 1];
15+
list[j + 1] = num;
16+
}
17+
}
18+
}
19+
return list;
20+
}

readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ Code | Test
3131
[Quick Sort](https://github.com/larissalages/code_problems/blob/master/classical_algorithms/java/QuickSort.java) | Missing tests
3232
[Bubble Sort](https://github.com/larissalages/code_problems/blob/master/classical_algorithms/java/BubbleSort.java) | Missing tests
3333

34+
### Dart
35+
Code | Test
36+
------------ | -------------
37+
[Bubble Sort](https://github.com/larissalages/code_problems/blob/master/classical_algorithms/dart/BubbleSort.dart) | Missing tests
38+
3439
### C++
3540
Code | Test
3641
------------ | -------------

0 commit comments

Comments
 (0)