Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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