Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2013
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. require 'pry'
  2.  
  3. first = 'FF'
  4. second = 'FB'
  5. third = ''
  6.  
  7. test = Array.new
  8. test.push('')
  9. test.push('FB')
  10. test.push('FF')
  11. test.push('')
  12. test.push('FB')
  13. test.push('FF')
  14. test.push(first)
  15. test.push(second)
  16. test.push(third)
  17.  
  18. # custom sort, should return FF < FB < ''
  19.  
  20. puts test.sort do |left,right|
  21. if left == first && right == second
  22. -1
  23. elsif left == first && right == third
  24. -1
  25. elsif left == second && right == third
  26. -1
  27. elsif left == right
  28. 0
  29. else
  30. 1
  31. end
  32.  
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement