foldLeftWithKey<A> method

A Function(A initial, A fun(A acc, K key, V value)) foldLeftWithKey<A>(
  1. Order<K> order
)

Apply fun to all the values of this Map sorted based on order on their key, and return the result of combining all the intermediate values.

Implementation

A Function(A initial, A Function(A acc, K key, V value) fun)
    foldLeftWithKey<A>(Order<K> order) =>
        (A initial, A Function(A acc, K key, V value) fun) {
          final sorted = toIterable(order);
          var result = initial;
          for (final item in sorted) {
            result = fun(result, item.key, item.value);
          }
          return result;
        };