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
  • 375,296
  • 67
  • 796
  • 848
borchero
  • 5,562
  • 8
  • 46
  • 72

1 Answers1

2

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

array.sort({
    $0.name < $1.name
})
erdekhayser
  • 6,537
  • 2
  • 37
  • 69