Programming in Swift - Part 47: Part 5: Structures: | Ray Wenderlich

Practice writing methods on your own, through a hands-on challenge.

This is a companion discussion topic for the original entry at

I’m being told that the sort method on collections has been replaced with sorted(by: ), is this just something that has been updated between Swift 3 and 4?

Yeah you can do the same thing with sorted(by:) like this:

students.sorted(by: { student 1, student2 in return student1.grade > student2.grade })

This topic was automatically closed after 166 days. New replies are no longer allowed.