S
S
Sir0zha2019-10-23 17:16:26
Swift
Sir0zha, 2019-10-23 17:16:26

How to sort arrays in a dictionary by key value?

var interestingNumbers = ["primes": [2, 3, 5, 7, 11, 13, 15],
                          "triangular": [1, 3, 6, 10, 15, 21, 28],
                          "hexagonal": [1, 6, 15, 28, 45, 66, 91]]
// Решение

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
doublench21, 2019-10-23
@Sir0zha

UPD: The author changed the question. The answer is not valid.
You have to do your own homework! Also close questions.

text
[
  "primes": [2, 3, 5, 7, 11, 13, 15],
  "triangular": [1, 3, 6, 10, 15, 21, 28],
  "hexagonal": [1, 6, 15, 28, 45, 66, 91],
].sorted { $0.key < $1.key }

// [
//   (key: "hexagonal", value: [1, 6, 15, 28, 45, 66, 91])
//   (key: "primes", value: [2, 3, 5, 7, 11, 13, 15]),
//   (key: "triangular", value: [1, 3, 6, 10, 15, 21, 28]),
// ]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question