Swift: How to sort an Array
Sometimes, an app needs to shot the information inside an array.
Thank you for reading this post, don't forget to subscribe!
Here’s a simple way to sort an array and print it to the console:
import UIKit
import Foundation
var names = [“Kelly”,”Michael”,”Danny”,”Sam”,”Ralph”,”Cathy”,”Thomas”,”Scott”]
names.sort()
print (names)
- First, you put information inside the array.
- Then, you use the sort command.
- Finally, you print the results to the console, a UILabel, or an UITableView.
About Post Author
(Visited 15 times, 1 visits today)