I have a number of values that can change, and would like to know the closest of them to the number ten (Double), which I do by sorting an array of properties.

I realise that as they're Doubles the array cares about the data type than the property, which is my problem as I would like to locate the one closest (but not including) ten, and then amend it back to ten e.g. if value2 is eight, and this is the closest of all the values, or at least the first in the array to meet that condition if there are multiple, then to amend that to ten:

```
var value1: Double = 10
var value2: Double = 10
var value3: Double = 10
var value4: Double = 10
let allValues = [value1, value2, value3, value4, value5]
for value in allValues {
if value < 10 {
var organisedValues = allValues.sorted() { $0 > $1 }
organisedValues[1] = 10 //first result will always be 10, so avoid
}
}
```

Likely the code above is not the way to achieve this, but what is please ?