Skip to content

Instantly share code, notes, and snippets.

@ibeauregard
Created June 12, 2021 16:42
Show Gist options
  • Save ibeauregard/02dc1b80c86f121c9f6e1d6264925e48 to your computer and use it in GitHub Desktop.
Save ibeauregard/02dc1b80c86f121c9f6e1d6264925e48 to your computer and use it in GitHub Desktop.
def order_by(rows, keys):
for key in reversed(keys):
def sort_key(row):
value = converted(row[key.index])
return (value == '' if key.ascending else value != ''), value
rows.sort(key=sort_key, reverse=not key.ascending)
return rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment