# This code will create a dataset in scripting, and then sort it based on the name of one of the columns.
# It then inserts the sorted dataset into a table component.
# Initialize column headers and empty data list
headers = ["City", "Population", "Timezone", "GMTOffset"]
data = []
# Add rows, one by one, into data list
data.append(["New York", 8363710, "EST", -5])
data.append(["Los Angeles", 3833995, "PST", -8])
data.append(["Chicago", 2853114, "CST", -6])
data.append(["Houston", 2242193, "CST", -6])
data.append(["Phoenix", 1567924, "MST", -7])
# Convert headers and data lists into dataset
cities = system.dataset.toDataSet(headers, data)
# Sort the resulting dataset by city name
newData = system.dataset.sort(cities, "City")
# Write final dataset to a table
event.source.parent.getComponent('Table').data = newData |