1

I have (in swift 1) this line of code:

keys = sorted(namesDict!.allKeys as! [String]) 

but function sorted is not supported anymore (Swift 2.0). What can i write to have keys sorted?

Thanks!

1
  • 3
    The answer seems to be in the question's title already. Commented Sep 22, 2015 at 7:27

1 Answer 1

1

I think you have answered your own question. The sort function returns a sorted array, you can store it in a variable.

let dict = ["b":1, "a":2, "c":3] let sortedKeys = dict.keys.sort() //returns ["a", "b", "c"] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.