Skip to content

Instantly share code, notes, and snippets.

@oshinko
Last active March 15, 2024 08:11
Show Gist options
  • Save oshinko/cd0ca89aff473ab390a8e4710d58ad04 to your computer and use it in GitHub Desktop.
Save oshinko/cd0ca89aff473ab390a8e4710d58ad04 to your computer and use it in GitHub Desktop.
For the ToDo list of Google Spreadsheet
function sort() {
const TARGET_SHEETS = ['全て']
const sheet = SpreadsheetApp.getActiveSheet()
if (!TARGET_SHEETS.includes(sheet.getName()))
return
const [_, targetColumn] = sheet
.getRange(1, 1, 1, sheet.getMaxColumns())
.getValues()
.flat()
.map((x, i) => [x, i + 1])
.find(([x]) => x === '優先順')
const range = sheet.getRange(1, targetColumn, sheet.getMaxRows())
if (range.getValues().flat().some(x => x === ''))
return
sheet.sort(targetColumn)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment