I would suggest the following:
1 - If your Customers
type is not what I changed to Customer
in my example, then, you should make your customers
array an array of Customer
([Customer]
). By the way, you don't need the initializer call since you are initializing the array in your initializer. You can get away with var customers : [Customer]
and you don't execute any code since you are going to actually initialize later.
2 - Not sure what getAllCustomers
does, but, I'm assuming you are fetching rows from your database and initializing Customer
instances. If you are using the Customer
type, when you create an instance with two strings, you'll get an instance of Customer
with a custNumber
String, and a custName
CustName
or Customer.Name
depending on whose example you use. Key point is the the custName
property has the <
and ==
operators defined on it that you can now use in your sort
call. By the way, you should probably figure out what to do with if you get two names that are equal.