In this video we are going to take a look at Sorting Objects in Swift. In particular, we will be looking at the sorted(by:) instance method for sorting elements of a sequence using the provided predicate as the comparison between arguments.
After a short introduction, the focus will be on sorting objects using multiple criteria and in this section, I will show you how you can easily sort objects over multiple criteria and how to define default sort orders for your objects by implementing the Comparable protocol.
If you want to support my work, you can buy me a coffee :)
https://ko-fi.com/stewartlynch
******* Download my StewartLynch YouTube Channel Application - Free **********
https://stewartlynch.gumroad.com/l/obsjz
Table of Contents:
0:00 Introduction
1:22 Simple Type Array Sort
4:15 Sorting Objects by property or multiple criteria
10:28 Using Tuples to sort objects with multiple criteria
12:38 Creating Default sorts with Comparable Protocol
Starter Project Files:
http://www.createchsol.com/StarterPro...
Completed Project:
https://github.com/StewartLynch/Sorti...
Other references:
Earlier video that introduces sorted method:
• contains, forEach, sorted
Other References:
Stewart Lynch's YouTube Channel:
/ stewartlynch
Stewart Lynch on Twitter:
/ stewartlynch
CreaTECH Solutions Website:
https://www.createchsol.com
Stewart Lynch's GitHub:
https://github.com/StewartLynch