Skip to content

Instantly share code, notes, and snippets.

@thurloat
Created January 7, 2013 18:24
Show Gist options
  • Save thurloat/4477220 to your computer and use it in GitHub Desktop.
Save thurloat/4477220 to your computer and use it in GitHub Desktop.
if sort? and (sort.get "items").length > 0
parts = for item in (sort.get "items")
dir = if item[0] == "-"? then "DESC" else "ASC"
"#{ if dir == "ASC" then item else item.slice 1 } #{ dir }"
sql += " ORDER BY #{ parts.join ", " }"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment