Here's a little mathematical/coding question.
I'm trying to figure out the best way of inserting a Int within an array of Ints at the correct index for the array to be in numerical order lowest-highest.
One way would be to loop over the array and as soon as index +1 > than my number than insert it at index.
I wondered though if there was any kind of swifty way.
Something like:
let index = array.index(where: { ($0 < number && $1 > number) } )
I can't add two parameters to the closure though...
Any ideas?