Use LinkedHashMap everywhere to preserve order.
This commit is contained in:
@@ -184,7 +184,7 @@ fun mapping(): List<GenericFunction> {
|
||||
doc { "Returns a map of the elements in original collection grouped by the result of given *toKey* function" }
|
||||
typeParam("K")
|
||||
returns("Map<K, List<T>>")
|
||||
body { "return groupByTo(HashMap<K, MutableList<T>>(), toKey)" }
|
||||
body { "return groupByTo(LinkedHashMap<K, MutableList<T>>(), toKey)" }
|
||||
}
|
||||
|
||||
templates add f("groupByTo(map: MutableMap<K, MutableList<T>>, toKey: (T) -> K)") {
|
||||
|
||||
@@ -117,7 +117,7 @@ fun snapshots(): List<GenericFunction> {
|
||||
returns("Map<K, T>")
|
||||
body {
|
||||
"""
|
||||
val result = HashMap<K, T>()
|
||||
val result = LinkedHashMap<K, T>()
|
||||
for (element in this) {
|
||||
result.put(selector(element), element)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user