Swift: How to sort an Array | CompuScoop.com

This could be your banner!

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)

  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.

About Post Author

(Visited 15 times, 1 visits today)

You may have Missed:

Verified by MonsterInsights