If you are using the dataset on a table then Jordan’s suggestion of using "Line " as a column prefix is the way to go. This is done in the Table Customizer on the table. So you set "Line " as the prefix for the column and you populate the dataset with integers instead of “Line #” – because the table will insert the "Line " part for you if you use it as a prefix.
If you want a flexible, powerful way to sort a dataset the following way works:
#get the component that has the dataset
table = event.source.parent.getComponent('Table')
#convert the dataset into a MutablePyDataSet
data = pa.dataset.toData(table.data)
#sort the MutablePyDataSet
data.sortRows(key=lambda row: int(row["Line"].split(" ")[1]))
#convert it back into a Dataset and assign it to the table
table.data = data.toDataSet()
The sortRows method takes a function that is used to evaluate each row. The function returns a value to use to sort each row. lambda is Python syntax for creating an anonymous function on one line of code. The function that I passed in splits the “Line” column into a list on the space " " character, then it gets the second item in the list, which is where the number is, and converts the string number into an integer number, so that the integer number is used for sorting. You can see the documentation for the sortRows method here: doc.perfectabstractions.com/modu … -sort-rows