Skip to content

Commit

Permalink
Fix documentation of sort operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
renggli committed Sep 6, 2023
1 parent 071232d commit e64fe8b
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lib/src/comparator/operations/sort.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import 'package:collection/collection.dart';
extension SortComparator<T> on Comparator<T> {
/// Sorts the provided [list] in-place.
///
/// If [start] (inclusive) and [end] (exclusive) are provided the sorting
/// only happens within the specified range.
///
/// If [stable] is set to `true`, a stable merge-sort implementation is used
/// instead of the standard quick-sort. This means that elements that compare
/// equal stay in the order of the input.
///
/// If [start] (inclusive) and [end] (exclusive) are provided the sorting
/// only happens within the specified range.
void sort(List<T> list, {int? start, int? end, bool stable = false}) {
start ??= 0;
end ??= list.length;
Expand All @@ -21,15 +21,18 @@ extension SortComparator<T> on Comparator<T> {

/// Returns a sorted copy of the provided [iterable].
///
/// If [start] (inclusive) and [end] (exclusive) are provided the sorting
/// only happens within the specified range.
///
/// If [stable] is set to `true`, a stable merge-sort implementation is used
/// instead of the standard quick-sort. This means that elements that compare
/// equal stay in the order of the input.
///
/// If [start] (inclusive) and [end] (exclusive) are provided the sorting
/// only happens within the specified range.
/// By default a more efficient fixed-length list is returned, unless
/// [growable] is set to `true`.
List<T> sorted(Iterable<T> iterable,
{int? start, int? end, bool stable = false}) {
final list = List.of(iterable, growable: false);
{int? start, int? end, bool stable = false, bool growable = false}) {
final list = List.of(iterable, growable: growable);
sort(list, start: start, end: end, stable: stable);
return list;
}
Expand Down

0 comments on commit e64fe8b

Please sign in to comment.