I have an array of pdf files (see attached screenshot) that I need to sort alphabetically. Here is the code that generates the array, can anybody suggest changes to have the array sorted?
import UIKit
var pdfsArray = [String]()
class PDFListViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
let fm = FileManager.default
let path = Bundle.main.resourcePath!
let items = try! fm.contentsOfDirectory(atPath: path)
for item in items {
if item.hasSuffix(".pdf") {
pdfsArray.append(item.uppercased())
}
let sortedFiles = pdfsArray.sorted()
pdfsArray = sortedFiles
}
