Skip to content

Instantly share code, notes, and snippets.

@vishw33
Created April 11, 2018 17:16
Show Gist options
  • Select an option

  • Save vishw33/a460d71275d222b706763c1d196bdc9e to your computer and use it in GitHub Desktop.

Select an option

Save vishw33/a460d71275d222b706763c1d196bdc9e to your computer and use it in GitHub Desktop.
extension Array where Element == Person
{
func arrangePersonsByAge() -> [Element]
{
var arr = self
arr.sort { (a, b) -> Bool in
a.age > b.age
}
return arr
}
func arrangePersonsBySalary() -> [Element]
{
var arr = self
arr.sort { (a, b) -> Bool in
a.salary < b.salary
}
return arr
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment