-3

I have an array of objects. Each object has a key "username".

Is there a swift way of sorting this array of objects into ascending order?

(array(at: indexPath.row) as AnyObject).value(forKey: "username") as? String)!

Thanks

2

1 Answer 1

3
yourArray.sorted({ $0.username < $1.username})
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.