Follow Us on Apple News

Sometimes, an app needs to shot the information inside an array.

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)

  1. First, you put information inside the array.
  2. Then, you use the sort command.
  3. Finally, you print the results to the console, a UILabel, or an UITableView.