diff --git a/libraries/stdlib/jvm/src/kotlin/collections/MapsJVM.kt b/libraries/stdlib/jvm/src/kotlin/collections/MapsJVM.kt index 202ce7a90c2..a1cab00afe8 100644 --- a/libraries/stdlib/jvm/src/kotlin/collections/MapsJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/collections/MapsJVM.kt @@ -45,15 +45,20 @@ public inline fun ConcurrentMap.getOrPut(key: K, defaultValue: () - /** - * Converts this [Map] to a [SortedMap] so iteration order will be in key order. + * Converts this [Map] to a [SortedMap]. The resulting [SortedMap] determines the equality and order of keys according to their natural sorting order. + * + * Note that if the natural sorting order of keys considers any two keys of this map equal + * (this could happen if the equality of keys according to [Comparable.compareTo] is inconsistent with the equality according to [Any.equals]), + * only the value associated with the last of them gets into the resulting map. * * @sample samples.collections.Maps.Transformations.mapToSortedMap */ public fun , V> Map.toSortedMap(): SortedMap = TreeMap(this) /** - * Converts this [Map] to a [SortedMap] using the given [comparator] so that iteration order will be in the order - * defined by the comparator. + * Converts this [Map] to a [SortedMap]. The resulting [SortedMap] determines the equality and order of keys according to the sorting order provided by the given [comparator]. + * + * Note that if the `comparator` considers any two keys of this map equal, only the value associated with the last of them gets into the resulting map. * * @sample samples.collections.Maps.Transformations.mapToSortedMapWithComparator */ @@ -64,6 +69,8 @@ public fun Map.toSortedMap(comparator: Comparator): Sorte * Returns a new [SortedMap] with the specified contents, given as a list of pairs * where the first value is the key and the second is the value. * + * The resulting [SortedMap] determines the equality and order of keys according to their natural sorting order. + * * @sample samples.collections.Maps.Instantiation.sortedMapFromPairs */ public fun , V> sortedMapOf(vararg pairs: Pair): SortedMap =