Skip to content

Commit be25d0c

Browse files
committed
Fix errors on sorts
1 parent 7e43209 commit be25d0c

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

lib/sorts/distribution.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ List<T> bucketSort<T extends num>(List<T> list, {bool desc = false}) {
148148
buckets[idx].add(list[i]);
149149
}
150150

151-
var sorted = buckets.fold(<T>[],
152-
(List<T> acc, el) => acc + insertionSort(el));
151+
var sorted =
152+
buckets.fold(<T>[], (List<T> acc, el) => acc + insertionSort(el));
153153
return desc ? sorted.reversed.toList() : sorted;
154154
}

test/sorts/distribution_test.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ import 'package:test/test.dart';
33
import 'package:algorithms/sorts/distribution.dart';
44

55
void main() {
6-
List<int>? randomList, positiveRandomList, sortedRandomListAscending,
7-
sortedRandomListDescending, sortedPositiveRandomListAscending,
8-
sortedPositiveRandomListDescending, allNegatives, someNegatives,
9-
sortedAllNegatives, sortedSomeNegatives, emptyList;
6+
List<int>? randomList,
7+
positiveRandomList,
8+
sortedRandomListAscending,
9+
sortedRandomListDescending,
10+
sortedPositiveRandomListAscending,
11+
sortedPositiveRandomListDescending,
12+
allNegatives,
13+
someNegatives,
14+
sortedAllNegatives,
15+
sortedSomeNegatives,
16+
emptyList;
1017
List<double>? randomDistribution, randomDistributionSorted;
1118
setUp(() {
1219
emptyList = [];

test/sorts/exchange_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ void main() {
1919

2020
test('Bubble Sort', () {
2121
expect(bubbleSort(randomList!), equals(sortedRandomListAscending));
22-
expect(
23-
bubbleSort(randomList!, ascendingFn), equals(sortedRandomListAscending));
22+
expect(bubbleSort(randomList!, ascendingFn),
23+
equals(sortedRandomListAscending));
2424
expect(bubbleSort(randomList!, descendingFn),
2525
equals(sortedRandomListDescending));
2626

test/sorts/selection_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ void main() {
2121
expect(heapSort(randomList!), equals(sortedRandomListAscending));
2222
expect(
2323
heapSort(randomList!, ascendingFn), equals(sortedRandomListAscending));
24-
expect(
25-
heapSort(randomList!, descendingFn), equals(sortedRandomListDescending));
24+
expect(heapSort(randomList!, descendingFn),
25+
equals(sortedRandomListDescending));
2626

2727
expect(heapSort(emptyList!), equals(emptyList!));
2828
expect(heapSort(emptyList!, ascendingFn), equals(emptyList!));

0 commit comments

Comments
 (0)