Sorting data topic
Sort and reorder lists of values.
Functions
-
ascending(
Object? a, Object? b) → num Sorting data -
Returns -1 if
a
is less thanb
, or 1 ifa
is greater thanb
, or 0. -
descending(
Object? a, Object? b) → num Sorting data - Returns -1 if a is greater than b, or 1 if a is less than b, or 0.
-
permute<
T> (Iterable< Sorting dataT> iterable, Iterable<int> keys) → List<T?> -
Returns a permutation of the specified
iterable
using thekeys
. -
permuteMap<
K, V> (Map< Sorting dataK, V> map, Iterable<K> keys) → List<V?> -
Returns a permutation of the specified
map
using thekeys
. -
quickselect<
T extends List< (E> , E>T elements, num k, {num left = 0, num right = double.infinity, int compare(E, E) = ascendingDefined}) → T Sorting data - See mourner/quickselect.
-
reverse<
T> (Iterable< Sorting dataT> iterable) → List<T> -
Returns an list containing the values in the given
iterable
in reverse order. -
shuffle<
T> (List< Sorting dataT> list, [int start = 0, int? stop]) → List<T> -
Randomizes the order of the specified
list
in-place using the Fisher–Yates shuffle and returns thelist
. -
shuffler<
T> (num random()) → List< Sorting dataT> Function(List<T> , [int, int?]) -
Returns a shuffle function given the specified
random
source. For example, using randomLcg: -
sort<
T> (Iterable< Sorting dataT> iterable, [num comparator(T, T) = ascending]) → List<T> -
Returns an list containing the values in the given
iterable
in the sorted order defined by the givencomparator
. -
sortBy<
T, R> (Iterable< Sorting dataT> iterable, R accessor(T), [num comparator(R, R) = ascending]) → List<T> -
Returns a list containing the elements of the given
iterable
in the sorted order defined by the values yielded by the givenaccessor
function.