Skip to content

Instantly share code, notes, and snippets.

@xander-miller
Created June 25, 2015 19:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xander-miller/1cf66969323b9189bf64 to your computer and use it in GitHub Desktop.
Save xander-miller/1cf66969323b9189bf64 to your computer and use it in GitHub Desktop.
Used a lamda to DRY up my code. Ruby skill up! 👍
res.sort! do |x,y|
archived = -> (z) {[:archived, 'archived'].include?(z.status)}
if archived.call(x) && archived.call(y)
0
elsif !archived.call(x) && archived.call(y)
-1
elsif archived.call(x) && !archived.call(y)
1
elsif !archived.call(x) && !archived.call(y)
0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment