'Sort Smartsheet rows with Python API
I'm using the Python SDK that Smartsheet provides but I'm unsure how to sort the rows. I have two date columns. I want to sort by Date1 and then by Date2 and then assign the rows in that sort order a number. I have no idea how to do this so any help would be welcomed.
Solution 1:[1]
There is a method within the SDK that sorts the rows of a sheet, either in ascending or descending order. You'll want to update the sortCriteria -- SortCriterion array..
sort_specifier = smartsheet.models.SortSpecifier({
'sort_criteria': [smartsheet.models.SortCriterion({
'column_id': COLUMN_ID,
'direction': 'DESCENDING'
})]
})
sheet = smartsheet_client.Sheets.sort_sheet(COLUMN_ID, sort_specifier)
See here for further documentation: https://smartsheet-platform.github.io/api-docs/index.html?python#sort-rows-in-sheet
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tyler |
