0

I have an Array called "myArray". In this array I have several objects from a custom NSObject class where I have 2 properties named "name" and "age". Now I want to sort the objects in the Array in alphabetic order by the property "name". I know how to do this in Objective-C but I really don't have an idea how to do this in Swift. Would be great if someone could help me.

rob mayoff
  • 358,182
  • 62
  • 756
  • 811
borchero
  • 4,964
  • 7
  • 42
  • 72

1 Answers1

2

This implementation of sort should be what you are looking for:

array.sort({
    $0.name < $1.name
})
erdekhayser
  • 6,361
  • 2
  • 35
  • 67