Skip to content

Instantly share code, notes, and snippets.

@Que20
Created July 23, 2019 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Que20/d86a74a8bc26d6c1e8785bbcd289dd2a to your computer and use it in GitHub Desktop.
Save Que20/d86a74a8bc26d6c1e8785bbcd289dd2a to your computer and use it in GitHub Desktop.
Sorted array of objects.
struct A {
var v: Bool
var s: String
}
var arr = [A(v: false, s: "asd"), A(v: true, s: "zxc"), A(v: true, s: "sdf")]
arr = arr.sorted(by: { $0.v && !$1.v })
print(arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment