// Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:collection';

import 'package:angular_components/model/ui/has_renderer.dart';

/// Sorts a list of items using the ItemRenderer to obtain a string
/// representation.
List<String> sortItems(ItemRenderer itemRenderer, Iterable entities,
    {bool ignoreCase: false}) {
  if (ignoreCase) {
    return new SplayTreeMap<dynamic, String>.fromIterable(entities,
        key: (Object c) => itemRenderer(c).toLowerCase()).values.toList();
  }
  return new SplayTreeMap<dynamic, String>.fromIterable(entities,
      key: (Object c) => itemRenderer(c)).values.toList();
}

// Copyright (c) 2016, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:collection';

import 'package:angular_components/model/ui/has_renderer.dart';

/// Returns a new list of items sorted according to the string obtained from
/// [itemRenderer].
///
/// [itemRenderer] should return a unique string representation for each item.
List<T> sortItems<T>(ItemRenderer<T> itemRenderer, Iterable<T> items,
    {bool ignoreCase: false}) {
  if (ignoreCase) {
    return new SplayTreeMap<String, T>.fromIterable(items,
        key: (T item) => itemRenderer(item).toLowerCase()).values.toList();
  }
  return new SplayTreeMap<String, T>.fromIterable(items,
      key: (T item) => itemRenderer(item)).values.toList();
}

Fix columns to be ordered alphabetically by columnGroup first, then by display name.
Fix columns to be ordered alphabetically by columnGroup first, then by display name.

PiperOrigin-RevId: 177896573
