Skip to content

Commit

Permalink
Merge pull request #27 from blackhammer25/master
Browse files Browse the repository at this point in the history
added selection sort for dart
  • Loading branch information
aniketsharma00411 authored Oct 1, 2020
2 parents 45f7dcc + 8c4aaa6 commit 9d9afb3
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Dart/selection_sort.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
void selectSorting(List list) {
if (list == null || list.length == 0) return;
int num = list.length;
int i, steps;
for (steps = 0; steps < num; steps++) {
for (i = steps + 1; i < num; i++) {
if(list[steps] > list[i]) {
change(list, steps, i);
}
}
}
}

void change(List list, int steps, int i) {
int count = list[steps];
list[steps] = list[i];
list[i] = count;
}

0 comments on commit 9d9afb3

Please sign in to comment.