Guest User

Untitled

a guest
Dec 14th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. struct MyObject {
  2. let someBool: Bool
  3. }
  4.  
  5. var MyObjects = [
  6. MyObject(someBool: true),
  7. MyObject(someBool: true),
  8. MyObject(someBool: false),
  9. MyObject(someBool: true),
  10. MyObject(someBool: false),
  11. MyObject(someBool: false),
  12. MyObject(someBool: true),
  13. ]
  14.  
  15. let resorted = MyObjects.sorted { $0.someBool && !$1.someBool }
  16.  
  17. /**
  18. true
  19. true
  20. true
  21. false
  22. false
  23. false
  24. */
  25. _ = resorted.map { print($0.someBool )}
Add Comment
Please, Sign In to add comment