I have a dictionary like below,
var dataSource: [String: String] = ["FirstName": "Austin", "ListName": "Michael", "Address": "Street Address", "City": "Chennai"]
I want to populate these values in a UITableView
, so I tried to get all the keys
from Dictionary
to an Array
like below,
let dataArray = Array(dataSource.keys)
I got the output as [String]
like,
["LastName", "FirstName", "City", "Address"]
The problem is, the order of the keys has changed, I want the array
in the same order as dictionary
has.
Can you anyone help?