Question: Looked online to get a better understanding of both Xcode and Swift and I've tried some things out and get errors. I'm using Xcode 8.2.1. I've tried using `sort`, but I'm for the version of swift I have it's `sorted(by:)` and I haven't gotten it to work so far. If you can please explain what I need to do and maybe leave an example that would be much appreciated!

There are 4 tasks I'm supposed to do.

1. Assign a list of unique random numbers to 5 variables and 5 constants. (Not sure if the way I did it was right or if I should use
`Int(arc4random_uniform(50))`.
2. Place them in an array
3. Sort by ascending order
4. Store them in a dictionary using key values to retrieve the highest and lowest number easily.

I'll leave my code here.

[![code snippet](https://i.stack.imgur.com/L8xiy.png)](https://i.stack.imgur.com/L8xiy.png)

Answer: 
Yes, you should probably use arc4random\_uniform to generate your random numbers.

If you must store your results into a dictionary (this is silly, as Rob points out in his comment) I would suggest using a dictionary of type `[Int:Int]`. That way you can use the array indexes as the keys.

Thus your dictionary declaration would be something like this:

```
var resultsDict: [Int:Int] = [:]

```

You could populate your dictionary using

```
for (index, value) in array.enumerated {
  resultsDict[index] = value
}

```

Then you could fetch the first result using

```
resultsDict[0]

```

And fetch the last result using

```
resultsDict[resultsDict.count - 1]

```
from use case it makes no sense place them in variables and constants

my solution would be:

```
// 1. Assign a list of unique random numbers to 5 variables and 5 constants. why variables and constants?
// 2. Place them in an array
var arr = (1...10).map{ _ in Int(arc4random_uniform(50)) }
print(arr) // -> [19, 41, 27, 47, 12, 38, 38, 48, 5, 41]

// 3. Sort by ascending order 
arr.sort()
print(arr) // -> [5, 12, 19, 27, 38, 38, 41, 41, 47, 48]

// 4. to retrieve the highest and lowest number easily
print(arr.first!) // -> 5
print(arr.last!)  // -> 48

```

or in short:

```
var arr2 = (1...10).map{ _ in Int(arc4random_uniform(50)) }.sorted()

print(arr2)        // -> [4, 5, 14, 20, 21, 27, 30, 37, 39, 43]
print(arr2.first!) // -> 4
print(arr2.last!)  // -> 43

```