// Copyright (c) 2023, 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. /// Provides utility extensions for JSON encoding. extension MapSorting, V extends Object?> on Map { /// Sorts the map entries on key. void sortOnKey() { final result = {}; final keysSorted = keys.toList()..sort(); for (final key in keysSorted) { result[key] = this[key] as V; } clear(); addAll(result); } }